Answer the question
In order to leave comments, you need to log in
Mikrotik. How to make automatic reconnect depending on IP?
There is a connection to the provider via PPPoE, dynamic IP.
According to the tariff, a “white” IP should always be issued, but sometimes a provider sometimes issues an IP behind its NAT, which causes external access to stop working. You have to manually reconnect the connection to get a normal IP.
Interested in automation. I know what can be implemented using scripts, but I'm not good at writing them.
What is required: if the IP on the interface is from 10.0.0.0/8, enable/disable this connection.
Answer the question
In order to leave comments, you need to log in
Isn't it easier in this case to set up Watchdog Timer and specify your static IP in it?
If the router gets a different IP, then it will reboot. Wait times can be configured there.
System-Watchdog
I've done it this way. Here, even in telegrams, the message is thrown back, but you can do without.
in On Up:
/log info "ISP Connected, timeout 30s...";
:delay 30s
:local curIP [/ip address get [find interface="Rostelecom"] address]; :put $curIP
:if ($curIP in 100.64.0.0/10) do={
/tool fetch url=" https://api.telegram.org/bot13XXXXXXXXXX:AAHWol7bw... bad address got! - $curIP";
/interface pppoe-client disable Rostelecom
:delay 5s
/interface pppoe-client enable Rostelecom
} else {
/tool fetch url=" https://api.telegram.org/bot13XXXXXXXXXX:AAHWol7bw... GOOD address got! - $curIP" ;
}
in On Down:
/log info "ISP Disconnected!";
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question