How to create a reconnection script Mikrotik pppoe client on the basis of the analysis of the first octet of the IP?

You know, the question has been raised. Based on this script, corrected to reconnect the pppoe client with the purpose to leave from the IP address that is unreachable from the outside:
:delay 10
:local "currentIP" [:pick [/ip address get [find interface =pppoe-out1] address ] 0 2]
:while ($currentIP = 82) do={
/interface pppoe-client enable pppoe-out1
}

Please indicate on error, the script does not want to work.... I understand that the script in 4 lines of debug is not difficult, but Mikrotik is remotely hard reboot when trying to obtain an address from accessed from outside the subnet....

After reading the script, which suffered 3 days (don't laugh, it was late in the evening...:) realized that in the while loop - do not check "currentIP". Most likely it would be logically correct:
:delay 10
:local "currentIP" [:pick [/ip address get [find interface =pppoe-out1] address ] 0 2]
:while ($currentIP = 82) do={
/interface pppoe-client enable pppoe-out1
:delay 2
:local "currentIP" [:pick [/ip address get [find interface =pppoe-out1] address ] 0 2]
}


But somewhere near should be a more elegant solution...
In such implementations more than one octet?
:while ($currentIP = 82 | 83) ?
July 9th 19 at 11:23
1 answer
July 9th 19 at 11:25
Solution
Read carefully the response to the script that you had based. There is a simple and very pretty solution (not mine). Easily modified to fit your needs:
:global newIP [/ip address get [find interface="PPPoE"] address];

:if (($newIP in 82.0.0.0/8)||($newIP in 83.0.0.0/8)) do={

/interface pppoe-client disable PPPoE
:delay 30
/interface pppoe-client enable PPPoE
}


Scripts it is very convenient to register in the PPP profile. Copy the profile specifically for this connection, there implant, and enjoy )
PS. I'm sorry, you were correct. Check again.
Mikritik swears on not true the or operator... - nikita.Stracke commented on July 9th 19 at 11:28
try to replace or with || - neva_Metz commented on July 9th 19 at 11:31

Find more questions by tags Mikrotik