Use loopback/dummy ip for packets originating from router, destined for default gateway

I have a routing protocol that announces 10.23.23.1/32 on Router A to an upstream router B, over two different uplinks.

How can I specify that any traffic that originates from router A towards the default route (which is on Router B) should use the loopback/dummy0 IP as the source IP, regardless of which uplink is currently the "active" default route.

Right now, the issue is that if Uplink 1 is active, packets originate from uplink 1's Ip address, and the connection fails if Uplink 2 takes over.

This is not a NAT issue, it's a source IP selection problem. hosts behind Router A, do not have an issue.

You can use ip rule and sometimes it's enough to just use the src flag when using ip route. But I'm not sure if UCI supports to configure the src flag. The ip-full package gives you the full iproute2.

1 Like