Mês: julho 2013

Setting a backup default route for quagga in linux

Sometimes you don’t need to automate something, you just need to find a better setup with your existing tools.

I got some experience with Quagga for the last couple years, and it’s great. It’s seems to be a very very rare event, but I’ve been bitten by a crash in quagga once or twice. And that’s specially bad if that machine receives its default route through quagga and it ends up without any default route.

So I like to set a static backup default route, in case the dynamic one goes away. That’s usually good practice anyway. Just set a static one in linux with larger metric, someone said. But no. Not with Quagga. Quagga does not install a route if there’s already an existing off-quagga route for that destination, even with a different metric. Seems silly, but it’s true.

Workaround: use linux’s multiple routing tables feature. Check the link if you never heard of it. By default, you already have three tables, setup like this:

# ip rule
0:      from all lookup local
32766:  from all lookup main
32767:  from all lookup default

Quagga usually installs routes in the main table, which is the regular one. The ip rules above tell the kernel that if it does not find a route in main, it should look in the default table.  So all you need is:

ip route add default via x.x.x.x table default

Quagga will now install the dynamic default route in table main, because he didn’t find any default route there. But if that route somehow disappears, the one in the default table will kick in to save the day.