I’m using mikrotik and my isp keep changing my ip from time to time, sometime i get public ip or private ip, so to keep to get public ip i need to reconnect until i get public ip, here’s some script that i use :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 :local WANINTERFACE [CHANGE THIS WITH WAN PPPOE INTERFACE]
:local WANIP [/ip address get [find where interface=$WANINTERFACE ] value-name=address];
:set WANIP [:pick $WANIP 0 ([:len $WANIP]-3) ];
:if ($WANIP ~"^[0-9 ]*10") do={
:local c 0;
:log warning "Private ip address found !!!";
:log warning "Reset $WANINTERFACE !!!";
:do {
:set $c ($c+1);
/interface pppoe-client enable $WANINTERFACE;
:delay 15s
:set WANIP [/ip address get [find where interface=$WANINTERFACE ] value-name=address];
:set WANIP [:pick $WANIP 0 ([:len $WANIP]-3) ];
:log warning "Attempt $c IP : $WANIP !!!";
:delay 5s
} while=($WANIP ~"^[0-9 ]*10")
:log warning "Public IP - Found, OK ! end script";
} else={
:log warning "Public IP - $WANIP - Found, OK ! No action required";
}
don’t forget to add it to schedule and repeat it.