All Pages > howto > Routing daemons and dn42 > OpenBGPD
This guide describes a simple configuration for OpenBGPD running on OpenBSD. The portable version should run with little to no configuration changes on other operating systems as well.
Other than the bgpd.conf(5)
and bgpd(8)
man pages and the OpenBSD /etc/examples/bgpd.conf
, you might also find useful reference or ideas in the Bird2 page (even if you don't use Bird), as it likely presents the most widespread dn42 router setup.
Example configuration
When copying from the below configuration, be sure to at least replace the various <PLACEHOLDER>
s with your own numbers.
Concrete configuration examples can also be found elsewhere, e.g.:
https://smrk.net/text/openbsd-dn42-setup.txt
https://kaizo.org/2024/01/03/openbsd-bgpd/
Given OpenBGPD's limited support for multiprotocol sessions (no extended next hop (RFC8950)) and some issues with IPv6 link-local nexthops, we configure separate IPv4 and IPv6 sessions for each peer, and for IPv6 we adjust nexthop to a "global" address (i.e., one from our dn42 IPv6 allocation) assigned to each peering (Wireguard) interface (each interface gets its own).
To avoid burning a dn42 IPv4 address for each peering, we put the router's dn42 IPv4 address on a loopback interface and have bgpd
bind to that address (local-address
in bgpd.conf
) when opening IPv4 BGP sessions; each peering interface gets an IPv4 address from an RFC1918 subnet (192.168.42/24), and a static route to the corresponding peer via that address.
/etc/hostname.lo42
<YOUR-ROUTER-DN42-IPv4>
<YOUR-ROUTER-DN42-IPv6>
!route -qn add -blackhole <YOUR-DN42-IPv4-PREFIX>
!route -qn add -blackhole <YOUR-DN42-IPv6-PREFIX> ::1
/etc/hostname.wg1234
(one example; similar for each peer)
::1 64<YOUR-DN42-IPv6-OF-PEER1-INTERFACE> 64
my_dn
21234 wgkey <PRIVKEY-BASE64>
<PEER1-PUBKEY-BASE64> \
"dn42 peer1" \
fe80::/64 wgaip fd00::/8 wgaip wgaip \
<PEER1-HOSTNAME-OR-IP> 24321
up
!route -nq add <PEER1-IPv4>
fe80
/etc/pf.conf
(only the dn42-related snippet)
-pkt-rate 30/3
<YOUR-ROUTER-DN42-IPv4>
<dn42etc> {172.20/14 172.31/16 10/8 fd00::/8}
<dn42peers> {<PEER1-IPv4> fe80::/64}
in quick on egress proto udp to port 21234
out quick on my_dn proto tcp to <dn42peers> port bgp !received-on any
in quick on my_dn proto tcp from <dn42peers> \
to {$dn42_self (my_dn)} port bgp
in log quick on my_dn to {$dn42_self (my_dn)}
on my_dn from <dn42etc> to <dn42etc> no state
in quick proto {icmp icmp6} max
/etc/bgpd.conf
ASN = "<YOUR-AS-NUMBER>"
ID = "<YOUR-ROUTER-DN42-IPv4>"
AS $ASN
$ID
mydn42 {
<YOUR-DN42-IPv4-PREFIX>
<YOUR-DN42-IPv6-PREFIX>
}
dn42etc {
.20.0.0/14 prefixlen 21 - 29.20.0.0/24 prefixlen >= 28.21.0.0/24 prefixlen >= 28.22.0.0/24 prefixlen >= 28.23.0.0/24 prefixlen >= 28.31.0.0/16 or-longer.100.0.0/14 or-longer.127.0.0/16 or-longer.0.0.0/8 prefixlen 15 - 24:/8 prefixlen 44 - 64 }
include "/var/db/openbgpd/dn42_roa_obgpd_46.conf"
prefix-set mydn42 set {
64511:<READ-THE-LINK-ABOVE>
64511:<READ-THE-LINK-ABOVE>
$ASN:1:1
}
on $ID
on <PEER1-IPv6-LOCAL>
dn42peers {
1000 restart 60
<PEER1-IPv4> {
peer1_4
<PEER1-ASN>
$ID
}
<PEER1-IPv6-REMOTE> { peer1_6
<PEER1-ASN>
nexthop <YOUR-DN42-IPv6-OF-PEER1-INTERFACE>
}
}
quick from ebgp prefix-set mydn42 or-longer
quick from any max-as-len 10
from group dn42peers prefix-set dn42etc ovs valid
to group dn42peers prefix-set dn42etc
from ebgp set { large-community delete $ASN:*:* }
from any community GRACEFUL_SHUTDOWN set { localpref 0 }
ROA
The roa-set
for route origin validation (ovs valid
in the config above) can be generated from the dn42 registry; here we use data conveniently provided by BURBLE-MNT.
If using the update script below, don't forget to create the /var/db/openbgpd/
directory first.
/root/openbgpd-roa-update.sh
#!/bin/sh
# Unfortunately, burble regenerates the ROA files (hourly?)
# even when nothing changed, so If-Modified-Since doesn't
# help (similar story for .meta).
metafile=/var/db/openbgpd/registry.meta
err= ||
if ! ; then
roafile=/var/db/openbgpd/dn42_roa_obgpd_46.conf
if err=; then
else
fi
else
fi
/var/cron/tabs/root
~ * * * * -ns /root/openbgpd-roa-update.sh
Looking glass
This is mostly OpenBSD specific since bgplg(8) and httpd(8) ship as part of the operating system. The bgplg manual contains the steps and example httpd.conf(5) required to enable the looking glass.
See https://lg-dn42.vinishor.xyz/bgplg (IPv6) for a running instance operating within DN42.