12

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

ckujau
  • 633
  • 4
  • 13
Taron
  • 121
  • 5
  • What version are you running (`uname -a` should show)? – Chris S Jul 09 '13 at 14:45
  • FreeBSD 8.2-RELEASE FreeBSD 8.2-RELEASE #0: Fri Apr 15 12:45:40 MSD 2011 root@grs.ru:/usr/src/sys/amd64/compile/IXI_8_2_PF_x64 amd64 – Taron Jul 09 '13 at 16:38
  • The gateway in your first routing table and the first hop in your traceroute aren't the same (.53 vs .54) - did you copy and paste or re-type this? Can you also post the full output of `netstat -rnf inet`? – James O'Gorman Jul 10 '13 at 07:52
  • traceroute running from my GW (.54), .53 is IP first provider`s device. – Taron Jul 10 '13 at 10:33
  • Are both gateways connected to the same interface? The netstat -rn output you show has em3 for both gateways. Perhaps you need to specify the -interface option to the route change command. – Craig Jul 12 '13 at 22:01
  • 6
    Clear the ARP cache `arp -d -a` and/or routing tables `route flush` before adding the new default route. Possibly the kernel/user space is consulting stale data. – inetplumber Sep 08 '13 at 20:11

2 Answers2

0

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

$ sudo /etc/rc.d/netif restart
kenorb
  • 5,943
  • 1
  • 44
  • 53
0

Is it possible you have a cached route to 8.8.8.8? The full output of netstat -nr would show that. If so you would need to remove it before testing your change - either that route specifically or you could route flush and then add rather than change the default gateway (but bare in mind this will interrupt non-local traffic whilst between the two commands if you go that way).

user133831
  • 191
  • 1
  • 3