I had 1 ISP, and this hairpin script that worked
Code: Select all
# this is the global variable holding the last known public IP
:global HairpinPreviousIP ;
# get the current WAN IP
:local currentIP ;
:do {
:set currentIP [/ip address get [find interface=ether1-gw] address] ;
} on-error={
# you could add a failover static IP here, just have something so the script won't fail
:set currentIP 192.168.0.1 ;
}
# Strip the net mask off the IP address
:for i from=( [:len $currentIP] - 1) to=0 do={
:if ( [:pick $currentIP $i] = "/") do={
:set currentIP [:pick $currentIP 0 $i] ;
}
}
# Public IP has changed
:if ($currentIP != $HairpinPreviousIP) do={
# clear the address list
:foreach entry in=[/ip firewall address-list find list="Hairpin"] do={
/ip firewall address-list remove $entry
}
# add new address to the address list
/ip firewall address-list add list="Hairpin" address=$currentIP
# here you could also add other static router IPs to the Hairpin list
# /ip firewall address-list add list="Hairpin" address=192.168.1.2
# store the new IP
:set HairpinPreviousIP $currentIP ;
}
Now I have 2 different ISP. Both are pppoe and I have a simple failover (just put different distances).
I'm really lost, looking for a way to select ISP that is already working
This script is fine when you know that your wan is a single interface, but in my case won't work: pppoe-out1 and pppoe-out2 are both active with public-dynamic IP.