Community discussions

MikroTik App
 
SergKz
just joined
Topic Author
Posts: 8
Joined: Sat Feb 06, 2010 8:33 am

Howto disable/delete a route by parameters, not by number?

Sun Jul 31, 2016 4:25 am

I have mikrotik router (RB2011) connected to three external networks by PPPoE (via different providers).
All of them has default route, and there are a number of static routes, addressed to the gateway of a particular provider
I wrote a script to deactivate some of static routes and activate another one, if PPPoE  interface goes down.
But I don't know the number of route, that is nesessary to disable/enable/delete routes - the number of routes may be chanched by order of PPPoE interface start or if it was temporary disconnected.
So, how can I disable/enable/delete route by it parameters - network, gate, etc?
 
IntrusDave
Forum Guru
Forum Guru
Posts: 1286
Joined: Fri May 09, 2014 4:36 am
Location: Rancho Cucamonga, CA

Re: Howto disable/delete a route by parameters, not by number?

Sun Jul 31, 2016 7:30 am

This should do it for you:
/ip route remove [find gateway="192.168.1.1"]
 
IntrusDave
Forum Guru
Forum Guru
Posts: 1286
Joined: Fri May 09, 2014 4:36 am
Location: Rancho Cucamonga, CA

Re: Howto disable/delete a route by parameters, not by number?

Sun Jul 31, 2016 7:31 am

you can "find" anything that you can "set", for routes those would be
bhp-as-path
bhp-communities
bgp-med
bhp-prepend
comment
distance
gateway
route-tag
scope
type
numbers
bhp-atomic-aggregate
bhp-local-pref
bhp-origin
check-gateway
disabled
dat-address
pref-src
routing-mark
target-scope
vrf-interface
 
 
SergKz
just joined
Topic Author
Posts: 8
Joined: Sat Feb 06, 2010 8:33 am

Re: Howto disable/delete a route by parameters, not by number?

Sun Jul 31, 2016 7:49 am

This should do it for you:
/ip route remove [find gateway="192.168.1.1"]
Thank you, it works!
But another question is: how can I prevent the inactivation of a static route when the gateway is unavailable?
This is useful when a route is used to check the path to the external host through certain external connection.
 
IntrusDave
Forum Guru
Forum Guru
Posts: 1286
Joined: Fri May 09, 2014 4:36 am
Location: Rancho Cucamonga, CA

Re: Howto disable/delete a route by parameters, not by number?

Sun Jul 31, 2016 7:52 am

I don't think you can. Once the router is unable to talk to the gateway, it will disable the route until it is available again. 
 
SergKz
just joined
Topic Author
Posts: 8
Joined: Sat Feb 06, 2010 8:33 am

Re: Howto disable/delete a route by parameters, not by number?

Sun Jul 31, 2016 8:00 am

I don't think you can. Once the router is unable to talk to the gateway, it will disable the route until it is available again. 
I found the same.

Apparently, it is necessary to use to check the availability of the way network address of a particular service provider, which is not available through their external interface.
I will be think :-)
 
soheiliz
just joined
Posts: 10
Joined: Mon May 11, 2020 8:18 am

Remove useless route

Sun May 31, 2020 10:41 am

Hi Dears
I have a problem and I was thankful if someone helps me.
I have several numbers of 951 routers as my clients and I want to remove some useless routes in them without any disconnection or remove other routes. The point is that some of these useless route's gateways were PPTP and L2TP which they are removed and they changed to "unknown" and the route is static and not active. Some of them
I have used (/IP route remove [/ip route find gateway="unknown"]) but it didn't help me.
is there any script which removes routes by their flag (S- Static the blue lines) and not manual or one by one or using the line numbers. As I said I have several routers and use ssh for all of them.

Best Regards,
 
SirAdams
just joined
Posts: 11
Joined: Sat Oct 11, 2014 1:16 pm
Contact:

Re: Remove useless route

Wed Sep 01, 2021 5:25 pm

I have used (/IP route remove [/ip route find gateway="unknown"]) but it didn't help me.
/ip route print for check
0 S 192.168.x.0/24 *F16EA3 20
1 S 192.168.x.0/24 *F177AF 20

/ip route remove [find static gateway~"F1*"];
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Howto disable/delete a route by parameters, not by number?

Wed Sep 01, 2021 6:35 pm

/ip route remove [find where gateway~"^\\*[0-9a-fA-F]{1,8}\$"]

Who is online

Users browsing this forum: No registered users and 15 guests