MikroTik – Auto reboot/reset interface when lost connection

MikroTik - Auto reboot/reset interface when lost connection

Router MikroTik often hangs and loses connection and does not automatically reconnect. The best way is to create a script that automatically detects and restarts the network interface. H2Ttool will guide you How to create auto reboot/reset interface when lost connection on MikroTik RouterOS.

Idea: Create a script that automatically pings google regularly. When detecting ping not reaching the destination, it will automatically restart the interface connecting to the internet.

Login to your MikroTik router

Use Winbox to access your MikroTik router device. Fill in the form: Connect To, Login, Password and press Connect.

Use Winbox to access your MikroTik router device

Setup Netwatch – Create auto reboot/reset interface when lost connection

Step 1: Look at the toolbar on the left, choose Tools -> Netwatch

Tools -> Netwatch

Netwatch window appears, select the + to add new Netwatch Host.

In Net Netwatch Host window you can enter as shown below:

  • Host: IP to ping check connection, i choose google ip (8.8.8.8). You can choose any ip you want to check.
  • Interval: hh:mm:ss – ping test execution time.
  • Timeout: Maximum response time, default is 1s = 1000ms. If the response time from the Host exceeds the above time, Netwatch will execute the command in the Down tab, if not use Up tab.

Install the script in the Up and Down tabs -> Click OK to finish:

:log info "NETWATCH--Auto check ping google..."
:if ([/ping 8.8.8.8 count=5]=0) do={
log info "NETWATCH--Check ping down, auto reset Interface/Wireless Port!" ; /interface disable ether2 ; delay 5000ms ; /interface enable ether2}
Enter the script in the Up and Down tabs -> Click OK to finish.

/ping 8.8.8.8 count=5 -> You can choose another IP and number of ping packets

/interface disable ether2 and /interface enable ether2 -> You need to choose the correct interface or wireless connection to the internet to check.

  • If you use INTERFACES use this example: /interface disable ether2
  • If you use WIRELESS use this example: /interface wireless disable wlan1

Watch tutorials on youtube

Good luck! If there are configuration problems or need to be discussed, do not hesitate to leave a comment below the article!

Bài viết này được đăng trong MikroTik và được gắn thẻ .

5 bình luận về “MikroTik – Auto reboot/reset interface when lost connection

Để lại một bình luận