Hi, I’m kind of new and I still learning.
I had 1 ISP, and this hairpin script that worked
# 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.
You can use scripts in PPP profile, just use this as “On Up”:
:local Name [/interface pppoe-client get $interface name]
/ip firewall address-list remove [find where list=Hairpin comment=$Name]
/ip firewall address-list add list=Hairpin address=$"local-address" comment=$Name]
and this as “On Down”:
:local Name [/interface pppoe-client get $interface name]
/ip firewall address-list remove [find where list=Hairpin comment=$Name]
It will update the list every time PPPoE clients connects or disconnects. Normally the list will contain both addresses, and that’s fine. Only if you’d want incoming connections to work for both at the same time, you’d need to make sure that you route responses the same way from where requests came.