Changing default or static route gateway on 2.5.0 does not remove old route
2.5.0 has multi-path (RADIX_MPATH) enabled in its kernel (#9544) which allows multiple routes to the same destination to exist in the routing table.
This leads to a problem when changing the default gateway on system_gateways.php. When the user selects a different default gateway, then saves and applies changes, the old default is not removed:
WAN gateway selected as default:
: netstat -rn4 | grep default default 198.51.100.1 UGS em0
Default changed to WAN2 gateway, then save/apply:
: netstat -rn4 | grep default default 198.51.100.1 UGS em0 default 203.0.113.1 UGS em2
The second route must be removed by hand (e.g.
route delete default 198.51.100.1), or a reboot would also clear it.
#2 Updated by Viktor Gurov 4 months ago
Jim Pingle wrote:
This also affects static routes. Changing a route gateway does not remove the old route.
It is possible to add parser to route_add_or_change() to delete existing route on change,
but it is better to fix it in FreeBSD
simple example from route(8) is not working:
EXAMPLES ... Add a static route to the 172.16.10.0/24 network via the 172.16.1.1 gate- way: route add -net 172.16.10.0/24 172.16.1.1 Change the gateway of an already established static route in the routing table: route change -net 172.16.10.0/24 172.16.1.2
# route add -net 172.16.10.0/24 172.16.1.1 add net 172.16.10.0: gateway 172.16.1.1 # route change -net 172.16.10.0/24 172.16.1.2 route: route has not been found change net 172.16.10.0: gateway 172.16.1.2 fib 0: not in table