Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting source IP when adding a static route / set src #17886

Open
SwimGeek opened this issue Jan 20, 2025 · 9 comments
Open

Setting source IP when adding a static route / set src #17886

SwimGeek opened this issue Jan 20, 2025 · 9 comments

Comments

@SwimGeek
Copy link

Hi

I see you can use 'set src' in a route-map, to set the source IP when a route is installed.

I was hoping to set a source IP for a static route. Is there a reason this is not supported?

https://docs.frrouting.org/en/stable-10.2/static.html

@ton31337
Copy link
Member

Which use case do you have in mind? set src is mostly used with ip[v6] protocol ... route-map ... to set the source IP to the arbitrary destination. One use case example would be BGP unnumbered.

@SwimGeek
Copy link
Author

Hi

It sometimes happens that a router connected to peering points will use the peering point IP as source address when doing things like apt-get for package updates or running offsite backups.

Wanted to add a static route which sets the source IP in frr.conf - just to keep all the static routes in one place.

@ton31337
Copy link
Member

Can you show how are you trying to use it?

@SwimGeek
Copy link
Author

Very similar to adding a route in Linux:

ip route add n.n.n.n/32 via m.m.m.m src x.x.x.x

...when routing to n.n.n.n/32, set source IP to x.x.x.x

@ton31337
Copy link
Member

I meant how do you do in frr.conf?

@SwimGeek
Copy link
Author

as far as I can see this can't be done in frr.conf - not supported in the syntax for adding a static route

@ton31337
Copy link
Member

It works for me fine.

route-map a permit 10
 set src 192.168.10.139
exit
!
ip route 100.100.100.201/32 192.168.10.1
!
ip protocol static route-map a
!

Output:

donatas# show ip route 100.100.100.201/32
Routing entry for 100.100.100.201/32
  Known via "static", distance 1, metric 0, best
  Last update 00:00:57 ago
  * 192.168.10.1, via wlp0s20f3, rmapsrc 192.168.10.139, weight 1

In the kernel:

# ip route show 100.100.100.201
100.100.100.201 nhid 16 via 192.168.10.1 dev wlp0s20f3 proto 196 src 192.168.10.139 metric 20 

@ne-vlezay80
Copy link
Contributor

Why set nexthop attribute from ip protocol?

@SwimGeek
Copy link
Author

I was trying to set the source IP, without needing a route-map - but I figured out another solution.

The route map + 'set src' way of doing it can also work for what I need.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants