User Tools

Site Tools


routeros

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
routeros [2024/05/13 08:09] – created protocolrouteros [2026/09/23 14:16] (current) – protocol
Line 1: Line 1:
 +===== Known your IP =====
 +<code>
 +/tool fetch https://wtfismyip.com/text output=user
 +</code>
 +
 +
 +===== Balance =====
 +
 +[[balance]]
 +
 +
 +===== OSPF watchdog when default route vanishes, set your variables! =====
 +
 <code> <code>
 :local HOSTNAME ([/system identity get name]) :local HOSTNAME ([/system identity get name])
Line 4: Line 17:
  /routing ospf instance set 0 disabled=yes  /routing ospf instance set 0 disabled=yes
  /routing ospf instance set 0 disabled=no  /routing ospf instance set 0 disabled=no
- /log error "$HOSTNAME SEM OSPF"+ /log error "$HOSTNAME NO OSPF"
  :delay 4000ms;  :delay 4000ms;
  /tool fetch url="https://api.telegram.org/bot$BOT_ID/sendMessage?chat_id=$CHAT_ID&text=$HOSTNAME NO OSPF, OSPF RESTARTING" keep-result=no  /tool fetch url="https://api.telegram.org/bot$BOT_ID/sendMessage?chat_id=$CHAT_ID&text=$HOSTNAME NO OSPF, OSPF RESTARTING" keep-result=no
 }</code> }</code>
 +
 +===== something about wifi reg tables =====
 +<code>
 +
 +
 +:foreach ITEM in=[/interface wireless registration-table print] do={
 +  :local COMMENT [/interface wireless registration-table get $ITEM comment];
 +  :put "$COMMENT";
 +}
 +
 +:foreach a in=[/interface wireless registration-table] do={
 +  :put [interface wireless registration-table get $a comment]
 +}
 +
 +
 +:foreach i in [/interface wireless registration-table find] do={
 +  :find [/interface wireless registration-table get $i comment]
 +:put "$i"
 +  }
 +}
 +
 +{
 + :local registration [/interface wireless registration-table print where interface=wlan2 count-only];
 +  :if ($registration > 0) do={
 +/tool fetch url="https://api.telegram.org/xx/sendMessage?chat_id=866143904&text=wlan2 up" keep-result=no
 + }
 +}
 +
 +</code>
 +
 +===== MPLS basic =====
 +<code>
 +
 +/mpls ldp set enabled=yes lsr-id=172.26.0.101 transport-address=172.26.0.101
 +/mpls ldp interface add interface=ether2
 +/mpls ldp interface add interface=ether5
 +/interface vpls add remote-peer=172.26.0.103 vpls-id=3012:3012 pw-type=tagged-ethernet
 +/interface bridge port
 +add bridge=vlan3012-bridge interface=vpls1
 +add bridge=vlan3012-bridge interface=vpls2
 +add bridge=vlan3012-bridge interface=ether1
 +
 +</code>
 +
 +===== Automatic PPPoE creation local secrets =====
 +<code>
 +
 +{
 +    :put "Starting real-time PPPoE-only log monitor... Press [Ctrl+C] to stop.";
 +    
 +    # Initialize the log pointer to the very last current entry
 +    :local terminalLogID [/log find]
 +    :local lastID ""
 +    :if ([:len $terminalLogID] > 0) do={
 +        :set lastID ($terminalLogID->([:len $terminalLogID] - 1))
 +    }
 +
 +    # Continuous loop
 +    :while (true) do={
 +        # Filter logs containing authentication failure and include "user "
 +        :local logEntries [/log find where message~"authentication failed" and message~"user "]
 +        
 +        :foreach entry in=$logEntries do={
 +            # Process only newer entries than our saved marker
 +            :if ($entry > $lastID) do={
 +                :local logTopics [/log get $entry topics]
 +                
 +                # STRICT TOPIC CHECK: Ensure the log contains the 'pppoe' topic
 +                :if ($logTopics ~ "pppoe") do={
 +                    :local logMsg [/log get $entry message]
 +                    :local logTime [/log get $entry time]
 +                    
 +                    :local startPos ([:find $logMsg "user "] + 5)
 +                    :local endPos [:find $logMsg " authentication failed" $startPos]
 +                    
 +                    :if ($endPos > $startPos) do={
 +                        :local pppoeUser [:pick $logMsg $startPos $endPos]
 +                        
 +                        # Verify if it already exists
 +                        :if ([:len [/ppp secret find where name=$pppoeUser]] = 0) do={
 +                            /ppp secret add name=$pppoeUser password="12345" service=pppoe comment="Auto-created via pppoe log monitor"
 +                            :put "[$logTime] [PPPoE Match] Created user: $pppoeUser"
 +                        } else={
 +                            :put "[$logTime] [PPPoE Match] Missing user '$pppoeUser' detected, but secret already exists."
 +                        }
 +                    }
 +                }
 +                :set lastID $entry
 +            }
 +        }
 +        # 2-second delay before checking the log buffer again
 +        :delay 2s;
 +    }
 +}
 +
 +</code>
 +
routeros.1715598588.txt.gz · Last modified: by protocol