13

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
  • 651
Taron
  • 131

5 Answers5

1

Looks like you have something else in your routing tables. Have you tried to look at the route with the route command to see if it's using the default route or something else ?

route show 8.8.8.8

It should show default...

route show 8.8.8.8

 route to: dns.google
destination: default 
mask: default 
gateway: your-gateway.whatever 
  fib: 0 
interface: ixl3 flags:
<UP,GATEWAY,DONE,STATIC>
recvpipe sendpipe ssthresh rtt,msec mtu weight expire 
      0        0        0        0  1500   1     0

if it's not showing default and you need the ip it's use route -n

cpu
  • 11
  • 3
0

I don't know why I don't recognize the output from your netstat -rn command, but I'm used to seeing a NETMASK there.

Not sure why your netmasks aren't showing up, but since they're not, you might have completely incorrect netmasks and the certainly could be your problem.

0

From the output of the ping command, it seems that you are targeting the local IP address, rather than the remote gateway.

So if xxx.xxx.183.54/29 is assigned to your FreeBSD node (as seen under ifconfig) you need to use the next hop IP address which looks like it could be xxx.xxx.183.53/29. The same may be true in that the xxx.xxx.144.125 address is the address assigned to a local interface.

As an example, I have a machine with the following:

ifconfig:
  em0: flags=8863<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
  inet xxx.xxx.123.99 netmask 0xffffff00 broadcast xxx.xxx.xxx.255

em1: flags=8863<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500 inet xxx.xxx.234.99 netmask 0xffffff00 broadcast xxx.xxx.xxx.255

netstat -rn Destination Gateway Flags Netif Expire default xxx.xxx.123.254 UGS em0

In my example above , all traffic is currently going out of the em0 interfacec towards the ISPs #1 Router IP (xxx.xxx.123.254) as the next hop.

If I wanted to route all traffic out of em1, rather than em0 I would use: $sudo route change default xxx.xxx.234.1, if xxx.xxx.234.1 was my ISPs #2 router IP address on that LAN segment.

I would also suggest checking to see if dhclient is running with either ISP, as it maybe installing routes unbeknown to you in the background.

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
  • 7,125
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).