T
T
TheAndrey72021-11-10 14:13:53
Mikrotik
TheAndrey7, 2021-11-10 14:13:53

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

2 answer(s)
A
Anton Kuzovov, 2021-11-11
@iAHTOH

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

T
Ten, 2021-11-18
@Ten

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!";
6196040cd53b4327158919.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question