Community discussions

 
User avatar
lamersons
just joined
Topic Author
Posts: 7
Joined: Tue Dec 11, 2007 10:34 am

enable/disable route script

Tue Dec 11, 2007 11:25 am

hi m8s

Im new to scripting so give a break 8)
i need to make script that enables/disables route

Script: ip route {print}{disable 0}
It should disable route0 but it doesn’t. When I do it from command line it disables it, but as soon as I enter it into script source window it fails me. What do I do wrong ?

For example
Script: ip route add dst-address=x.x.x.x/x gateway=x.x.x.x
Works fine for me both command line and script source window.

using 2.9.46
MTCRE, HuaweiCNP, CCNP RS, CEHv7
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 5934
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: enable/disable route script

Tue Dec 11, 2007 12:04 pm

search the forum, this was asked so many times.

print then disable {number} doesn't work when used in scripts.
Please read the manual how to use find commad:
http://www.mikrotik.com/testdocs/ros/2. ... 9330088749
 
User avatar
lamersons
just joined
Topic Author
Posts: 7
Joined: Tue Dec 11, 2007 10:34 am

Re: enable/disable route script

Wed Dec 12, 2007 12:01 pm

in any case support have sent me the solution if any1 else needs 8)

---
It is not possible to use number of rule in scripts.
Because print is required before, it is not possible to run print in script.

So to make your script working, add comment to script like comment=gateway1, Then use the following script,

'ip route disable [find comment=gateway1]'
---
MTCRE, HuaweiCNP, CCNP RS, CEHv7
 
kuppavenkatakrishna
just joined
Posts: 1
Joined: Mon Dec 17, 2007 5:47 pm

Re: enable/disable route script

Mon Dec 17, 2007 6:16 pm

Hi,

Can you send me the script to my id kvkrisshna@yahoo.com

My actual necessity is
I have two ISPs connected to my mikrotik router both connected on ethernet Please find the diagram attached and due to the network design the failover does not happen for which i need a script which will disable the primary gateway (Point to Point IP of first ISP on ISP End) and should enable the secondary default route.

Help from anyone is appreciated.

Regards,
K.V.Krisshna
You do not have the required permissions to view the files attached to this post.
 
User avatar
ashish
Long time Member
Long time Member
Posts: 550
Joined: Mon Feb 12, 2007 5:50 am
Location: Virginia, USA.

Re: enable/disable route script

Tue Dec 18, 2007 6:03 am

Contact
http://www.mikrotik.com/consultants.html#country_India
Hi,

Can you send me the script to my id kvkrisshna@yahoo.com

My actual necessity is
I have two ISPs connected to my mikrotik router both connected on ethernet Please find the diagram attached and due to the network design the failover does not happen for which i need a script which will disable the primary gateway (Point to Point IP of first ISP on ISP End) and should enable the secondary default route.

Help from anyone is appreciated.

Regards,
K.V.Krisshna
- AP - ASHISH PATEL - 757 309 0236 -
 
mikman
just joined
Posts: 6
Joined: Tue Mar 03, 2009 9:06 am

Re: enable/disable route script

Sat Jun 06, 2009 11:17 am

Great Guys
You really solved my problem with enable/disable routes.

many thanks to lamerous

Appreciate it...

Mikman
 
Ecnival
just joined
Posts: 1
Joined: Wed Oct 31, 2018 7:43 am
Location: Okinawa, JP

Re: enable/disable route script

Tue Dec 18, 2018 6:29 am

in any case support have sent me the solution if any1 else needs 8)

---
It is not possible to use number of rule in scripts.
Because print is required before, it is not possible to run print in script.

So to make your script working, add comment to script like comment=gateway1, Then use the following script,

'ip route disable [find comment=gateway1]'
---
Thanks. This script worked perfectly for what I wanted to do!

I ran into a situation, where the default route for my L2TP connection would always become 'disabled' after a power-cycle, maybe. Which prevented the traffic from going through the VPN. After changing 'disable' to 'enable' and creating a scheduler to start after bootup, plus making it run every 10 minutes. This allowed me to successfully fix that issue.

Thanks!!

Who is online

Users browsing this forum: No registered users and 10 guests