Community discussions

MikroTik App
 
NPen
just joined
Topic Author
Posts: 1
Joined: Mon Feb 22, 2021 3:31 pm

Disable/Enable of port

Tue Feb 23, 2021 10:15 am

Hi there,

Is there a way to restart (disable/enable) the wan port (in this case ether2) when the connection is lost?

Thank you!
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 1911
Joined: Sat Dec 24, 2016 11:17 am
Location: jo.overland at gmail.com

Re: Disable/Enable of port

Tue Feb 23, 2021 11:33 am

This will disable interface and wait two seconds before it set to enable when there are noe link.
I would have examined what the problem is and try to solve it before adding some script like this.
Schedule it to run every 1 min (f.eks)
/interface ethernet monitor ether3 once do={
	:if ($status = "no-link") do={ 
		/interface set [find name=ether3] disabled=yes
		:delay 2s
		/interface set [find name=ether3] disabled=no
		:log error message="Interface lost connection"
	}
}
Some variation:
:local IF "ether3"
/interface ethernet monitor $IF once do={
	:if ($status = "no-link") do={ 
		set [find name=$IF] disabled=yes
		:delay 2s
		set [find name=$IF] disabled=no
		:log error message="Interface lost connection"
	}
}

Nearly same code post here:
viewtopic.php?f=9&t=172825
 
Why do not use Splunk to monitor your MikroTik Router(s)? Look at this page in how to set it up.

MikroTik->Splunk
 

Who is online

Users browsing this forum: No registered users and 22 guests