Last active
March 13, 2022 19:39
-
-
Save nucther/6441a808dd012ae3e4b6926f9beeeadd to your computer and use it in GitHub Desktop.
Mikrotik Tunnel broker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##### | |
# Tunnel Broker Update | |
##### | |
:global prevIP | |
:local inetIface "[PPPoE Interface Name]" | |
:local tunnerlbroker "[Tunnel broker URL]" | |
:local tunnelIface "[Tunnel 6to4 Internal Name]" | |
:local rejectIP 10.0.0/8 | |
:if ([/interface get $inetIface value-name=running]) do={ | |
:local currentIPtmp [/ip address get [find interface="$inetIface" disabled=no] address] | |
:local currentIP [:pick $currentIPtmp 0 ([:len $currentIPtmp]-3)] | |
:local networkIP [/ip address get [find interface="$inetIface" disabled=no] network] | |
:log info "Current IP: $currentIP" | |
:log info "Current GW: $networkIP" | |
:if ($currentIP in $rejectIP ) do={ | |
:log info "WAN using private IP" | |
/interface pppoe-client set $inetIface disabled=yes | |
:delay 15s | |
:log info "Dial Again" | |
/interface pppoe-client set $inetIface disabled=no | |
} | |
:if ($prevIp != $currentIP) do={ | |
:log info "Difference $prevIP = $currentIP" | |
:log info "Start He.Net" | |
:local updateHe [/tool fetch url="$tunnerlbroker" as-value output=user] | |
:log warning $updateHe | |
/interface 6to4 set $tunnelIface local-address=$currentIP | |
:set prevIP $currentIP | |
} else={ | |
:log info "IP same" | |
} | |
} else={ | |
:log warning "Inet Disabled" | |
:delay 10s | |
/interface pppoe-client set $inetIface disabled=no | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment