backup static routes for freebsd (default)

Ezra Banoba ezra at
Tue Aug 5 03:17:18 PDT 2003

Thanks Phil,
I tried some guesswork myself to add the secondary default routes router
style with weights and that's the only way the route add command will accept
another default route. I do not know how freebsd interpretes this:
route add default [gateway] [administrative weight]

though this has no effect when i birng down the default route.

Maybe a script to ping the gateways at intervals will do.
Any other ideas are welcome.

Ezra Banoba
Systems Administrator/Programmer
Computer Froniters International
Plot 32 Lumumba Avenue
+256 031260485

-----Original Message-----
From: owner-freebsd-questions at
[mailto:owner-freebsd-questions at]On Behalf Of Philip Payne
Sent: Tuesday, August 05, 2003 2:38 AM
To: 'Ezra Banoba'; freebsd-questions at
Subject: RE: backup static routes for freebsd (default)


> I have a gatway box running freebsd 4.8 and several links to
> the internet
> via different ISP's.
> This box is connected directly to one of the ISP's but also
> has access to
> the other gatways via the LAN.
> I would like to setup static backup (default) routes such
> that when and if
> the main link goes down, the default route for this box is
> automatically
> changed to point to another router on the LAN.I am having trouble
> implementing this on freebsd.
> Any ideas?

First, I'm more of a router person than familiar with how FreeBSD calculates
it's routing table so the following is all guesswork from "man route".

The issue with static routes is that they rarely have any idea of the status
of their destination but this can be fudged if you're using point-to-point
interfaces e.g. DSL, leased line. In general terms what you'd be doing on a
router is:

1) Have a default route directed out a point-to-point interface connected to
the ISP (not the IP address) so that when the interface is down, the static
route is removed from the live routing table.
2) Have a weighted default route via an alternative IP address. The weight
implies this route is only used when the former default route is not

I've read "man route" and I get the impression you can add a route via an
interface rather than a destination with the switch "-interface" so your
first step is to add a default route along the lines

> route add default -interface <int_name>

... this is a guess as the man page isn't explicit. Also, I don't know
whether this route remains live or is removed as required during a failure
on the point-to-point interface you'd configure this to. It definitely won't
work if your primary access method is a broadcast interface e.g. ethernet.

Further, I can't find any details on adding a weight to a static route to
create the secondary route so I'm not sure this is going to be possible via
an automatic routing table kind of thing.

So.....(getting to the point very slowly)

The only other method I can think of would be a script to ping the far end
addresses regularly in order. Depending on which one is up, you could inject
a default route statement as required to the correct destination.

I'd be interested in other suggestions as this doesn't sound entirely great
as there are many other reasons than link failure why an address wouldn't be

freebsd-questions at mailing list
To unsubscribe, send any mail to "freebsd-questions-unsubscribe at"

More information about the freebsd-questions mailing list