Bird2 and protocol Babel. auto change default gw
Toke Høiland-Jørgensen
toke at toke.dk
Mon May 16 13:06:29 CEST 2022
Michele Salerno <mikysal78 at gmail.com> writes:
> Hi,
> I am new to ML and also to using bird2.
> I use bird2 with babel protocol for routing the vpn server and openwrt
> router.
> The openwrt routers have a mesh wifi interface.
> My question is, if the wan (default gw) is down, can bird use the better
> mesh as the default gw?
>
> If the wan is restored, can it come back as default gw?
Yes! I have a setup similar to this on one of my routers, except the
opposite (the default is to use the babel-default route, wan is backup).
Your setup is actually simpler: you just need to connect Bird to a
separate routing table in the kernel and have that used with a lower
priority than the default; then, if the wan link goes down (making the
route disappear), the kernel will automatically switch over to the other
route. In OpenWrt, adding such a rule is quite simple - just add
something like this in /etc/config/network (see
https://openwrt.org/docs/guide-user/network/routing/ip_rules - you can
use any numeric value instead of '42', just make sure to pick one that's
not used for anything else):
config rule
option priority '50000'
option lookup '42'
config rule6
option priority '50000'
option lookup '42'
Then, configure bird to use table '42' instead of the default table (add
'kernel table 42'to the 'protocol kernel' stanza), and that should be
it. Note, however, that this will make *all* routes from Babel have a
lower priority than the wan link, so you won't be able to reach any
hosts on the mesh while the LAN is up. If you want to do the above for
*only* the default route, you'll need to have two separate 'protocol
kernel' instances in bird, one with 'kernel table 42' and one without,
and add filters so that only the default route goes to 'table 42'.
You'll need to configure another DNS server to get DNS lookup to work on
the OpenWrt box itself. I just added servers to the 'lan' interface
config like:
option dns '1.1.1.1 8.8.8.8'
And then you'll need to have a node on the mesh network that actually
exports 0.0.0.0/0 over Babel, of course.
-Toke
More information about the Bird-users
mailing list