Skip to main content

IPv6 configuration: worked, executable examples

TL;DR: Working examples of setting IPv6 addresses, nameservers and routes (static, SLAAC+RDNSS, SLAAC+stateless DHCPv6, and stateful DHCPv6), with client configuration for ifupdown (/etc/network/interfaces) and netplan, that you can run and experiment with on your own computer with minimal dependencies: github.com/daxtens/ipv6-config-demos

There are quite a few ways you can set up an IPv6 connection with enough information to be useful - an address, nameserver and default route. So far I've come up with 4, listed in the table below. (I found them all very confusing to begin with - the best explanation I've found online so far is this blog post.)

Method Address DNS Nameserver Default Route
Static Static Static Static
SLAAC + RDNSS Autogenerated by client RDNSS data in RA From RA
SLAAC + Stateless DHCPv6 Autogenerated by client DHCPv6 From RA
Stateful DHCPv6 Assigned by DHCPv6 server DHCPv6 From RA

I've been testing netplan - the default network configuration tool in Ubuntu 17.10 onwards - recently, so I wanted to be able to test each of these methods against both backends that netplan supports (systemd-networkd and NetworkManager) and the old-style ifupdown.

This seemed like an ideal use case for LXD/LXC - lightweight, virtual-machine-like containers. What drew me to this over Docker for this use case is that - unlike Docker - LXC containers have been build for the container-as-VM model, rather than the container-as-application-plus-dependencies model. In particular, daemons work as expected with minimal fuss. (If you've never heard of LXD before, a decent intro with a really nice theoretical/historical grounding is this this presentation from Dustin Kirkland.)

So I have created a script that sets up an set of LXD networks, one for each type of configuration in the table above. On each of those networks, there is a router which that runs the services necessary for each of those models, and 3 clients - netplan + networkd, netplan + NetworkManager and ifupdown. The routers are also each connected to a "backend" network that runs a DNS server, so that I can test that the machines do correct routing and DNS lookups.

That's a lot to take in: here is it in diagram format.

Diagram showing 'static', 'slaac-rdnss', 'slaac-dhcp6' and 'stful-dhcp6' networks. Each network contains a router, and a networkd, NetworkManager and ifupdown client. Each router is connected to a backend network, which also contains a 'backend' machine with a DNS server.

Getting this going was a bit fiddly and threw up some interesting - albeit fairly minor - bugs (LP: #1752211, LP: #1753860). The good news is that with appropriate configuration, they all work out of the box - no patches or recompilation required. I'm also working on making the netplan side of things simpler and better documented - so it will get even easier in the future.

The code and configuration is on GitHub - daxtens/ipv6-config-demos. You can run this entire setup on your local machine. So if you've ever wanted to set up an IPv6 network with Ubuntu but found the many and varied combinations and permutations of radvd and dhcpd confusing, you now have some working samples that you can spin up locally to experiment with and compare.

This setup requires a recent LXD, and may interfere with any existing LXD setup you have, so there's also a script to run it inside a virtual machine created with my favourite VM tool, uvtool. All the gory details of running it is in the README for the repository.

Feel free to use this as a way to explore netplan, IPv6, or LXC/LXD - or to do other cool things! Please do let me know how you go using this, or if you have any questions.

Comments

Popular posts from this blog

Connecting to a wifi network with netplan

How do you connect to a a wifi network with netplan? I hang out on the #netplan IRC channel on Freenode, and this comes up every so often. netplan - the default network configuration tool in Ubuntu 17.10 onwards - currently supports WPA2 Personal networks, and open (unencrypted) networks only. If you need something else, consider using NetworkManager directly, or falling back to ifupdown and wpa_supplicant for a little longer. Without further ado, here are tested, working YAML files for connection to my local WPA2 and unencrypted network. The only things that have been changed are the SSIDs and password. Both networks have a router providing dhcp4. In both cases I assume there's only one wifi device in the system - if this is not true, replace match: {} with something more specific. You can drop these in  /etc/netplan and run netplan generate; netplan apply  and things should work. The network will also be brought up on subsequent boots. Note that, as always in YAML, ind

Netplan by example

netplan  is the default network configuration system for new installs of Ubuntu 18.04 (Bionic). It uses YAML to configure network interfaces, instead of  /etc/network/interfaces . I've been testing netplan for a while, so in light of the release of Bionic, here's my set of examples, caveats, tips and tricks. Contents General tips and tricks Matching Basic IPv4 configuration MTUs Bridges, Bonds and VLANs Wifi IPv6 Supplementing or replacing netplan Going Further General tips and tricks Tabs are not allowed in YAML and currently you get a very useless error message if you use them: "Invalid YAML at //etc/netplan/10-bridge.yaml line 5 column 0: found character that cannot start any token". If you see this, check for tabs! Indentation matters in YAML. Make sure that things line up where they're supposed to. Rebooting is somewhat more reliable than netplan apply , but make sure  there are no errors in your YAML before you reboot or no network

Anonymous bridges in netplan

netplan is the default network configuration system for new installs of Ubuntu 18.04 (Bionic). Introduced as the default in Artful, it replaces /etc/network/interfaces . One question that gets asked repeatedly is: "How do I set up an anonymous bridge in netplan?" (An anonymous bridge, I discovered, is one where the bridge doesn't have an IP address; it's more akin to a switch or hub.) It's been approached on  Launchpad , and comes up on the IRC channel. If you're trying to create a bridge without an IP address, the obvious first thing to try is this: network: version: 2 ethernets: ens8: match: macaddress: 52:54:00:f9:e9:dd ens9: match: macaddress: 52:54:00:56:0d:ce bridges: br0: interfaces: [ens8, ens9] This is neat, plausible, and wrong - the bridge will be created but will stay 'down'. Per ip a : 5: br0: <BROADCAST,MULTICAST> mtu 15