My scenario here at home is:
RB4011
2 ISP WAN (pppoe-out1 / pppoe-out2)
Load Balance PCC / Failover
So my cry for help is:
I need some script to change the IP at /ip firewall nat. I have two ISP but one of them doesnt have the IP address fixed and when the link goes down the IP change and i need to do manually this change! I was using the default MASQUERADE but i need now this way. I tried to change the script at mikrotik wiki ip address changed but doesn't worked.
There is this explanation about masquerade and scrnat at mikrotik wiki:
This was the original script at mikrotik wiki:
Code: Select all
//SCRIPT DO SITE MIKROTIK
:global currentIP;
:local newIP [/ip address get [find interface="ether1"] address];
:if ($newIP != $currentIP) do={
:put "ip address $currentIP changed to $newIP";
:set currentIP $newIP;
}
Code: Select all
:global currentIP;
:local newIP [/ip address get [find interface="pppoe-out2"] address];
:local natIP [/firewall nat get [find comment="NAT VIVO" to-addresses];
:if ($newIP != $natIP) do={
:put "ip firewall nat $currentIP changed to $natIP";
:set currentIP $newIP;
}
Hello guys, i discovered some script here at forum and now it's done my script and running well on PPP profile when the pppoe goes UP again:
Code: Select all
:global status [/interface get pppoe-out2 running]
:if ($status) do={
:global old [/ip firewall nat get [find where comment="NAT VIVO"] to-addresses]
:global new [/ip address get [find where dynamic=yes and interface="pppoe-out2"] address]
:set new [:pick $new 0 [:find $new "/"] ]
:if ($new != $old) do={
/ip firewall nat set [find where comment="NAT VIVO"] to-addresses=$new
}
}