FreeBSD routing issues resolved

Today I had a call from a customer saying their Nagios server was showing incorrect ping results. Gconnect, (my $dayjob) host an MPLS network for this client which is in a transitive state between a traditional IPSec network and the new shiny MPLS VPN setup. As a result, ip prefixes move around between the MPLS gateway and the IPSec gateway, and the Nagios server has to keep track. During this time, the default gateway  for the Nagios server has changed, just to add further confusion! From the Nagios server I was unable to ping the target of, so trying to find out what was going on, I interrogated the Nagios server to see where it was looking for my target:

# route get
   route to:
  interface: em0
 recvpipe  sendpipe  ssthresh  rtt,msec    mtu        weight    expire
       0         0         0         0      1500         1      3597

Now is my old default gateway, the new one is My default router is set to:


And an attempt to reset the default route yeilds little help:

# route add default
route: writing to routing socket: File exists
add net default: gateway route already in table

So when I remove the specific route to the destination, like this:

# route delete
delete host

I now see the route as follows:

# route get
   route to:
destination: default
       mask: default
    gateway: haulfryn-0xydgp
  interface: em0
 recvpipe  sendpipe  ssthresh  rtt,msec    mtu        weight    expire
       0         0         0         0      1500         1         0

And I can now ping it! In a fit of enthusiasm I decided to remove all of the specific routes to clear any upcoming problems with the flush command:

# route flush
default              434-ws-002           done
runs-domain.sdsd        done
... clip ...
Write failed: Broken pipe

yes, thats what happens when the default route gets wiped out! To re-add it I went in via the console:

# route add default

And we’re back in the room – phew!

Additional Information

Here is how to clear all the routes in one go and not lock yourself out:

# route flush: route add default 'your_router_ip'

and you can see all of the ‘host routes’ in your table with:

# netstat -rl
This entry was posted in FreeBSD Administration and tagged . Bookmark the permalink.

Leave a Reply