Disable Interface on Startup and enable 1 minute later
RouterOS Scripting and API

Zapnologica
Long time Member
Long time Member
Posts: 583
Joined: Fri Sep 25, 2009 8:15 pm
Reputation: 0
First RouterOS version: 3.5
Location: South frica

Disable Interface on Startup and enable 1 minute later

by Zapnologica » Wed Feb 18, 2015 10:04 am

Good day,


I have a weird case in my one clients mikrotik. This is more of a work around than a solution but it will be quicker for me to do this.

I am routing voip data out of a different gateway. However my VoIP only starts routhign through the other line after I disable my primary internet line.

So basically I want a script that on startup, disables interface x.

waits a certain period of time and then Enables the interface again.


Can I do this?

User avatar
sergejs
MikroTik Support
MikroTik Support
Posts: 6477
Joined: Thu Mar 31, 2005 3:33 pm
Reputation: 12
First RouterOS version: 2.7
Location: Riga, Latvia

Re: Disable Interface on Startup and enable 1 minute later

by sergejs » Wed Feb 18, 2015 11:05 am

/system scheduler
provides you with such functions.

Run script on startup (there is such parameter), disable interface (be careful as small delay might be required for it), then add your proposed delay (:delay 60s) and command to enable interface.

Zapnologica
Long time Member
Long time Member
Posts: 583
Joined: Fri Sep 25, 2009 8:15 pm
Reputation: 0
First RouterOS version: 3.5
Location: South frica

Re: Disable Interface on Startup and enable 1 minute later

by Zapnologica » Wed Feb 18, 2015 12:02 pm

Any Ideas on what that specific script might look like? I haven't got much experience with the scripting language.

User avatar
sergejs
MikroTik Support
MikroTik Support
Posts: 6477
Joined: Thu Mar 31, 2005 3:33 pm
Reputation: 12
First RouterOS version: 2.7
Location: Riga, Latvia

Re: Disable Interface on Startup and enable 1 minute later

by sergejs » Wed Feb 18, 2015 12:15 pm

/system scheduler
add name=schedule1 on-event=":delay 5s;\r\
\n/interface ethernet disable ether1;\r\
\n:delay 60s;\r\
\n/interface ethernet enable ether1" policy=\
reboot,read,write,policy,test,password,sniff,sensitive start-time=startup

Zapnologica
Long time Member
Long time Member
Posts: 583
Joined: Fri Sep 25, 2009 8:15 pm
Reputation: 0
First RouterOS version: 3.5
Location: South frica

Re: Disable Interface on Startup and enable 1 minute later

by Zapnologica » Wed Feb 18, 2015 12:41 pm

This works in the terminal but not in a script?


am I doing something wrong? im running v6.26


Code: Select all

/interface pppoe-clinet disable Test


if I put that in a script and click run, nothing happens, put it in the terminal and it disables the interface?

User avatar
sergejs
MikroTik Support
MikroTik Support
Posts: 6477
Joined: Thu Mar 31, 2005 3:33 pm
Reputation: 12
First RouterOS version: 2.7
Location: Riga, Latvia

Re: Disable Interface on Startup and enable 1 minute later

by sergejs » Wed Feb 18, 2015 12:51 pm

Use scheduler to run script, make sure Test is the name of your PPPoE interface.

KabTak47
just joined
Posts: 1
Joined: Wed Feb 18, 2015 2:38 pm
Reputation: 0
First RouterOS version: 2.8.0

Re: Disable Interface on Startup and enable 1 minute later

by KabTak47 » Wed Feb 18, 2015 2:46 pm

At the moment RouterOS does not account milliseconds, and there are no too much setups where second is too big value for time.???
ali

Zapnologica
Long time Member
Long time Member
Posts: 583
Joined: Fri Sep 25, 2009 8:15 pm
Reputation: 0
First RouterOS version: 3.5
Location: South frica

Re: Disable Interface on Startup and enable 1 minute later

by Zapnologica » Wed Feb 18, 2015 9:43 pm

Does script and scheduler not run the same scripting language?

Ok sweet, It is working now in scheduler.

Who is online

Users browsing this forum: No registered users and 4 guests

It is currently Sat May 23, 2015 7:11 am