docs/docs/routing/babeld/babeld.md

219 lines
8.6 KiB
Markdown

# Configuring babeld
babeld is the reference implementation of the babel protocol. One difference to the bird implementation is that babeld can calculate the cost based on latency.
## Installation
In order to install the babeld on your machine you should look for a package named `babeld`. On a Debian-based system you can use:
```bash
sudo apt install babeld -y
```
To see if you have installed babeld correctly, you can view the babeld version:
```bash
babeld -V
```
If you are using a system with Systemd, you can enable babeld in the autostart:
```bash
sudo systemctl enable babeld
```
## Configuration
The babeld configuration file is normally located at `/etc/babeld.conf`.
### Full example
```
random-id true
link-detect true
default hello-interval 4
default type tunnel rtt-min 1 rtt-max 1001 max-rtt-penalty 1000 enable-timestamps true
interface <PEER> type tunnel
redistribute ip <OWNNET> eq <OWN LENGTH> allow
redistribute local deny
redistribute deny
in ip <OWNNET> deny
in ip fd00::/8 le 64 ge 44 allow
in deny
install pref-src <OWNIP>
```
Replace `<OWNNET>` with your prefix and `<OWN LENGTH>` with your prefix length.
```
random-id true
```
No explicit router ID is set by this instruction. Instead, a new random ID is generated at each startup. This allows the router to integrate itself into the network more quickly after a reboot.
```
link-detect true
```
When you peer with a peer, you do so through an interface. With this instruction babeld fetches information from the operating system. If the operating system tells babeld that the interface is down, the peer on this interface is considered down.
```
default hello-interval 4
```
Here you can set the default interval in which babeld Hello should send packets to its neighbors. As with bird, 4 seconds are set here.
```
default type tunnel rtt-min 1 rtt-max 1001 max-rtt-penalty 1000 enable-timestamps true
```
This statement specifies that the cost is equal to the latency. This only works if the peer also uses babeld.
```
interface <PEER> type tunnel
```
The individual peers are configured here. You can use `tunnel`, `wired` or `wireless` as type. Other parameters are adjusted accordingly. If you want to adjust the cost manually, you can write `rxcost <cost>`, replacing `<cost>` with the cost.
```
redistribute ip <OWNNET> eq <OWN LENGTH> allow
redistribute local deny
redistribute deny
```
Here the filters are defined, which come from the kernel into the babeld Routing Table. Only the own prefix is imported.
```
in ip <OWNNET> deny
in ip fd00::/8 le 64 ge 44 allow
in deny
```
Here the filters are defined, which routes are filtered from neighbors.
The own route is not accepted. Only ULA addresses are accepted. All other routes are filtered.
```
install pref-src <OWNIP>
```
This instruction ensures that the routes are installed with their own IP address as the source address.
The `out` and `install` filters are omitted. The babeld routing table contains only CRXN routes. Therefore no filtering must be made with the export into the kernel or to neighbors.
### Filter
babeld has a total of five filters:
- `in`
- `out`
- `redistribute`
- `redistribute local`
- `install`
The filter `in` filters routes coming from neighbors.
The filter `out` filters routes which are sent to neighbors.
The filter `redistribute` filters routes which are imported by the kernel.
The `redistribute local` filter filters routes that are imported from the kernel and bound locally to an interface.
The `install` filter filters routes that are installed into the kernel.
By default, all filters are set to `allow`. So all routes are accepted.
### Setting up the static routes
In order for babeld to know and propagate your own prefix, it must be statically defined. In bird you can do this with the `protocol static`. babeld takes its routing information from the kernel routing table. Therefore there must be a static route to its own prefix in the kernel routing table.
This can be created with the following command:
```
ip route add unreachable <OWNNET> proto static
```
This route does not survive a reboot (volatile). The protocol `proto static` is necessary, because babeld ignores the default protocol.
You can delete it with the following command:
```
ip route del <OWNNET>
```
## Start babeld
If you use a system with Systemd, you can use it to start:
```
sudo systemctl start babeld
```
Alternatively, you can start babel with the following command:
```
babeld -c <config>
```
`<config>` will be replaced with the path to the configuration file.
## Kernel parameters
Once babeld is started, forwarding is enabled in the kernel for IPv4 and IPv6. As soon as babeld is stopped, forwarding is deactivated again. A separate enabling like with bird is not necessary. So if you use babeld, you can ignore the steps of [IPv6 forwarding](../forwarding).
## Local configuration interface
There are two ways to activate the Local configuration interface. Once you can pass a command line argument for it or you can do this in the babeld configuration file.
### Command line argument
The local configuration interface can be activated with the flag `-g`. For example, to enable the configuration interface on port `33123`, you can use the following command:
```
babeld -g 33123
```
If babeld is used with Systemd, you can change the arguments in the `/etc/default/babeld` file:
```
DAEMON_ARGS="-S /var/lib/babeld/state -g 33123"
```
### Configuration file
To enable the local configuration interface there is a directive `local-port`:
```
local-port 33123
```
### Usage
The configuration interface can be used to find out various status information on the one hand and to configure babeld on the other. Furthermore, the configuration interface can be used by monitoring programs such as babelweb2.
To connect to the configuration interface, you can use telnet:
```
telnet ::1 33123
```
With the command `dump` you can display the current status:
```
dump
```
This should produce an output according to the following scheme:
```
add interface <interface> up true ipv6 <link-local>
```
The configured interfaces are displayed here. Here `<interface>` is the interface name and `<link-local>` is the own IPv6 link-local address.
```
add neighbour <nid> address <link-local> if <interface> reach ffff ureach 0000 rxcost <rxcost> txcost <txcost> cost <cost>
```
The babel neighbors are displayed here. Here `<nid>` is the router ID of the neighbor. `<link-local>` is the link-local address of the peer and `<interface>` is the interface over which the peer is connected. `<rxcost>` describes the amount of cost it takes to send data from the peer to us. These costs are set by us manually or automatically by babeld.
`<txcost>` describes the amount of cost it takes to send data to the peer. This value is set by the peer.
Information on how costs are calculated can be found in [RFC8966 3.4.3](https://www.rfc-editor.org/rfc/rfc8966#cost-computation) and [RFC8966 Appendix A](https://www.rfc-editor.org/rfc/rfc8966#name-cost-and-metric-computation).
```
add xroute <ownnet>-::/0 prefix <ownnet> from ::/0 metric 0
```
The networks that originate from us are displayed here. This should only be our own network. Here `<ownnet>` is the network we originate.
```
add route <nid> prefix <prefix> from ::/0 installed <installed> id <id> metric <rxcost> refmetric <neighbor> via <nexthop> if <interface>
```
The routes learned from the babel neighbors are displayed here. Here `<nid>` is the router ID of the neighbor and `<prefix>` is the prefix learned about the neighbor. `<installed>` is either `yes` or `no`. If `yes` the route was exported to the kernel, if `no` it was not. `<rxcost>` shows the cost of consuming to reach the prefix via this route. `<neighbor>` shows the cost our neighbor needs to reach the prefix. `<nexthop>` shows the nexthop, which is normally the IPv6 link-local address of our neighbor. `<interface>` shows the interface this route goes through. `<id>` is a unique ID to a route. The route keeps its ID until it is flushed.
## Further links
- [babeld homepage](https://www.irif.fr/~jch/software/babel/)
- [babeld MAC authentication](https://alioth-lists.debian.net/pipermail/babel-users/2021-June/003827.html)
- [babeld manuel](https://www.irif.fr/~jch/software/babel/babeld.html)
- [babeld FAQ](https://www.irif.fr/~jch/software/babel/faq.html)
- [babeld mailling list](https://alioth-lists.debian.net/pipermail/babel-users/)
- [babeld source code](https://github.com/jech/babeld)
- [RFC8966](https://www.rfc-editor.org/rfc/rfc8966)
- [Babel configuration by Réseau Libre](https://wiki.reseaulibre.ca/documentation/babel/)
- [Babel in Freifunk Franken (German)](https://wiki.freifunk-franken.de/w/Freifunk-Gateway_aufsetzen/babeld)