Upgrading the whole infrastructure
There is a major upgrade to my network. I got fiber connection at home so I took the time to change the IPSec stack I was not so happy with. My goal here is to replace the GRE+IPSec tunnels with Wireguard. Wireguard is nice because it is a true L3 only layer. The encapsulation footprint is quite small with an inner MTU of 1420.
I’ll post here from the moment I finished the local customization up to networking success. In 4 years since the begining of this blog a lot has changed in the software land with so much new options. Unfortunately, prices have not changed for the better and I keep my current dediboxes as they offer better price/performance compared to current offer.
Design goal
The plan is to keep the triange between home and 2 dediboxes. On home side, I also keep OpenBSD as VPN router. The main difference here, I have to think my home connection as outgoing flows only. The OrangeBox has a crappy limited interface when it comes to networking. The option to change the device with a dedicated router and ONT is not an option here. I don’t want to spend money on router and 10G switches for home use. Currently, the box is awful and is buggy enougth to not support incoming flows for fixed IPs inside LAN.
So, the prerequisites for the topology is as follow:
- Configuration should adapt to the CrappyLiveBox
- Subnets should be exchanged dynamically between each triange corner
- If one link goes down, the communication should continue to flow
- If I move one VM from one dedibox to the other, the modifications on host should be minimal
- Implement Public DNS master/slave zone
- Implement Internal DNS master/slave zone
Selecting technology and topology
As said earlier, I seleted Wireguard against IPSec because IPSec is complex and can be a pain to troubleshoot. Particuliarly, if you think I don’t have public IP any more and I have only outgoing flows available at the home edge.
With Wireguard, there are 2 main topologies to choose from. Either you build all VPNs on a single WG interface, therefore, you let Wireguard select the route to the destination by configuring dedicated prefixes per connection. Either you create as much interfaces as connections, and you decide routing ouside Wireguard. Because of my requirement to exchange subnets dynamically, I choose the 2nd option. Wireguard does not permit to select route based on availability and only use advertized prefixes at the tunnel establishement.
So on each node, I’ll have 2 interfaces, wg1 and wg2, corresponding to each tunnel. This setup has the disadvantage to use 2 UDP ports per host instead of 1 on normal operation.
Another cavehat, Debian requires either Stable distribution with kernel backported or Testing. At the begining I went to keep Stable and installed Wireguard from backports. Unfortunately, I ran into another issue with Libvirt that forced me to upgrade to Testing. To upgrade from Stable to Testing, please see your usual Debian source of information.
For the routing daemon on the OpenBSD side, I decided to keep OpenBGPd. It works (I never had a glitch) for my simple usecase and I was able to transcribe my needs into configuration easily. For the routing daemon on Debian, I had few choices: keep Bird or move to FRR. FRR comes from Quagga, a daemon I had issues with in the past, and not a very good feeling approach. FRR is certainly much better than Quagga by now, but I still have my bad experience in head. So I decided for Bird. The question now is what version of Bird I should aim for. I was happy with version 1.6, but all new devs are done on 2.0.x branch. The new reinstall was a perfect time to play with the new version. The drawback here, I have to compile bird from hand. Neither Debian nor Bird provice packages ready for Debian (maybe yes, I just didn’t find them). Bird provides packages for Ubuntu, not really my cup of tea.
Wireguard generate the encryption keys
The process is different on Debian and OpenBSD. The OpenBSD method requires you to bring an interface up and destroy it afterwards. Therefore I’ll show you here how to generate keys for all hosts on Debian. You will find the way to get keys from OpenBSD tooling while reading the blog post.
- Key material for Debian 1
- Key material for Debian 2
- Key material for OpenBSD
OpenBSD Wireguard configuration
The configuration of wireguard on OpenBSD is really easy. As always with OpenBSD, read the man page, it helps! Basically, I replaced the previous GRE interfaces with WG ones and adapted the configuration with Wireguard specific options: encryption, tunneled IPs. Here is the configuration of the 2 hostname.wg? interfaces:
The important point is to use a prefix with both endpoints on the inner addresses. In my case, I went from /32 to /30 so that I have one IP for the other side of the tunnel.
You’ll see also that I moved from IPv4 to IPv6 for outer connection. As CrapBox provides native IPv6 for internal LAN, why bother with NAT. At least it let me experiment the IPv4 inside IPv6 option :)
For the IP ranges allowed inside the tunnel, I’ve been very generous by adding the whole B and C classes private prefixes.
- Get IP from CrapLiveBox
- Generate secret key with openssl
- Create /etc/hostname.* files
file /etc/hostname.wg1
file /etc/hostname.wg2
- Get the public keys for each interface
- Bring up the tunnel
Debian IPv6 configuration
As often with Debian, everything is simple and complicated at the same time. Simple because things do work out of the box. Complicated because it’s never what you expect from standard package or does not match your needs.
First, getting IPv6 public IP is a challenge. Dibbler previously used is not supported anymore by Online.net. The new recommendation is to use dhcp client. I assume here, you get the Prefix Delegation ID (DUID) from the Web interface.
- Create the file /etc/dhcp/dhclient6.conf
- Configure RA on the egress interface to be able to forward and receive dhcp6 address
- Create the Systemd unit: /etc/systemd/system/dhclient.service
- Start and enable the daemon
- Now we have IPv6 prefix, add an IP address to the egress interface by adding this piece of code to /etc/network/interface
- Add the address by hand if you wish immediate connectivity
Debian Wireguard configuration
- Installing wireguard once on Testing was easy
- Create the keys following tutorials:
-
Configuration issues Once the configuration is in place, I had an issue with my VPN tunnels not working the way I expected. This is because by default Wireguard on linux insert routes configured for allowed IPs in the main routing table. OpenBSD did not have these defaults. Needless to say which way I prefer…
-
Final configuration for Wireguard on Debian: /etc/wireguard/wg1.conf
-
Use the same template for /etc/wireguard/wg2.conf file
-
Bring up the tunnel
- Check status
- Update Systemd to enable Wireguard at boot:
Testing
At that point, you need to update your firewall rules then you should be able to ping from 172.16.255.1 host to 172.16.255.2 and vice versa. If you want to route more subnets on each side, just add the prefixes with the traditionnal routing tools (route for OpenBSD and ip for Linux).
Next steps
The next blog post will be about enabling routing daemons to exchange prefixes between hosts.