Freebsd change default Internet channel route

channelfreebsdinternetroute

I have two Internet channel and Gateway on freebsd. When I switch channel with the command route change default chan2, the command netstat -nr shows changed default route. But traceroute shows that the packets go through the old route chan1.

Example:

$netstat -nr 
Routing tables Internet: Destination Gateway  Flags    Refs   Use  Netif Expire
                         default     xxx.xxx.183.54 US 0 8432    em3

$sudo route change default xxx.xxx.144.125 
change net default: gateway> xxx.xxx.144.125

$netstat -nr
Routing tables Internet: Destination Gateway Flags Refs Use  Netif Expire
                         default     xxx.xxx.144.125   US  2  16450  em3

BUT

$ traceroute 8.8.8.8
traceroute to 8.8.8.8 (8.8.8.8), 64 hops max, 52 byte packets
 1  xxx.xxx.183.53 (xxx.xxx.183.53)  0.527 ms  0.415 ms  0.483ms

All works if I run the following combination:

$sudo route del default

$sleep 10

$sudo route add default xxx.xxx.144.125

Best Answer

If you use route change command, you need to restart network service to apply the changes, e.g.:

$ sudo /etc/rc.d/netif restart