cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1628
Views
5
Helpful
11
Replies

Selective static route

babakip
Level 1
Level 1

Hi,

 

Here is the question. Is there any way to use a static route only if the source IP address of the packet is something special?

 

Imagine I have a static route as this:

 

ip route 10.10.10.0/24 5.5.5.2

 

I would like to use this static route only if the source IP address of coming packet be 192.168.0.20. This static route shouldn't be used for any other packet that doesn't have such a source IP.

 

I know that I can use "route-map + set ip next-hop" feature. But in this case, there is no need for a specific static route and a combination of "route-map" and "set ip next hop" is enough to route a packet based on a source IP address, while I would like to use a static route. 

 

Thanks in advance,

Bob

11 Replies 11

Jon Marshall
Hall of Fame
Hall of Fame

 

Routing is done based on destination IP address. 

 

If you want to route based on other criteria such as source IP that is what PBR is for. 

 

Jon

Hello,

 

a possible somewhat creative solution would be something like the below, where an EEM script would install the route whenever the source sends something. How long do you want the route to be in the routing table ?

 

Router#debug ip packet 1
!
access-list 1 permit host 192.168.0.20
!
event manager applet SOURCE_ROUTE
event syslog pattern "s=192.168.0.20"
action 1.0 cli command "enable"
action 2.0 cli command "conf t"
action 3.0 cli command "ip route 10.10.10.0 255.255.255.0 5.5.5.2"
action 4.0 cli command "exit"
action 5.0 cli command "clear log"
action 6.0 cli command "y"
action 7.0 cli command "end"

 

The problem with that solution is once the route has been entered into the routing table it then applies to all source IPs and not just 192.168.0.20 which is not what the OP wanted. 

 

Jon

Thanks Georg,

 

It's looks an interesting solution but I'm afraid to say it doesn't work in my case.

 

I need to have that static route permanent and the router uses it whenever meet the condition (receiving a frame with source ip: 192.168.0.20).

 

In your solution when router receives such a packet with source 192.168.0.20, it adds the static routes but it has two issues:

 

1- Static route will remain in router

2- When the static routes added to the router it will also apply to any other packet destined to 10.10.10.0/24 regardless of their source IP address.

 

Br,

Bob 

 

 

Hello,

 

that's why I was asking how long the route needs to stay in there. You could tweak the script to remove it when there is no traffic sourced from 192.168.0.20. Then again, as soon as the route is in there, all other traffic will use it too...

 

I'll see if I can think of something else than PBR...

Hello

I know that I can use "route-map + set ip next-hop" feature.

 

The above is policy based routing and it sounds as @Jon Marshall stated this is what you require otherwise anything else would also require a conditional action for path selection

PBR is designed to do exactly as you have queried other than installing a static route 


Please rate and mark as an accepted solution if you have found any of the information provided useful.
This then could assist others on these forums to find a valuable answer and broadens the community’s global network.

Kind Regards
Paul

Thanks for your comment. You are right but for some reason, I need to have the static route while PBR does routing without an explicit static route.

 

By the way, I have found something about "Configuring a static route for use with a route map" by using "tag" at the end of the static route and then use that tag in PBR :

 

http://docs.ruckuswireless.com/fastiron/08.0.60/fastiron-08060-l3guide/GUID-86D4047B-1599-45B0-9CBF-6E13207D5B43.html

 

But I couldn't find how to use that tag in PBR. If it works then I can use the Static route and PBR to meet my requirement.

 

\Bob

 

Why do you need the static route ?

 

Jon

Well, this is part of a customized solution that is not easy to explain here. I may open another case to discuss about that.

 

But it's surprising it is not possible to use a static route only in certain conditions!

 

\Bob

 

You can use a static route in certain conditions using IP SLA and tracking etc. but the fundamental issue remains the same ie. routing is based on destination IP address only. 

 

Jon

Thanks Jon for your reply,

 

Have you heard about this feature: "install-routes-recurse-via-nexthop" ?!

 

https://www.cisco.com/c/en/us/td/docs/ios-xml/ios/iproute_pi/configuration/15-s/iri-15-s-book/iri-rec-stat-route.html

 

It seems this is a feature to put a static route on the routing table with using PBR but I'm not sure how it works? At least it doesn't work for me when I try it. Or maybe it is something else!

 

Br,

Bob

Review Cisco Networking for a $25 gift card