Подключился к ростелекому и довольно часто по dhcp получаю белый ip адрес. Возник вопрос о скрипте проверки серого ip и если он серый делать пере подключение pppoe. За основу была взята статья Ростелеком. Проверка на серый IP
в профиле pppoe\scripts\on up
/system script run (script имя)
Создаем скрипт (script имя) в нем пишем:
Код: Выделить всё
:local WANInter "pppoe-ваше имя"
# get the current IP address from the internet (in case of double-nat)
/tool fetch mode=http url=http://ifconfig.co dst-path=ip.txt;
:local currentIPfile [/file get ip.txt contents];
# parse the current IP result
:local curetlen ([:len $currentIPfile] -1);
:local currentIP [:pick $currentIPfile 0 $curetlen];
:log info "On ifconfig.co Current IP is $currentIP";
#get WAN IP on interface
:local IpInterfaceCurrent [/ip address get [find interface=$WANInter] address];
:for i from=( [:len $IpInterfaceCurrent] - 1) to=0 do={
:if ( [:pick $IpInterfaceCurrent $i] = "/") do={
:local NewIP [:pick $IpInterfaceCurrent 0 $i];
:log info "WAN IP is $NewIP";
#Compare IP
:if ($currentIP = $NewIP) do={
#its normal
/log info "Connect OK";
} else={
#Gray IP. Do restart
/log info "Connected to gray IP";
/system script run (pppoe-ваше имя)
}
}
}
Код: Выделить всё
/interface pppoe-client disable (pppoe-ваше имя);
:delay 10;
/interface pppoe-client enable (pppoe-ваше имя);