With the release of Ubuntu 18.04 Bionic Beaver administrators need to learn new tools for network management, namely iproute and netplan.
iproute has been around for quite a while, so it’s not that new. It’s a replacement of ifconfig and it’s very easy and comfortable once you learn the syntax.
netplan instead is pretty new to me, I never heard about it before. I got to know about it thanks to an excellent What’s new page on DigitalOcean, and I found out my good ol’ /etc/network/interfaces has gone. So what’s now? a YAML configuration file! I’ve never been fond of yaml, but I also admit I never used it consistently, so let’s give it a hope.
Luckily I recently had to install a new VPS, and luckily again our currently favourite hosting provider, the incomparably cheap Contabo, already has Ubuntu 18.04 as available operating system! I couldn’t miss the chance!
After installing I wanted to change system’s DNS servers, as in the past I’ve had problems with Contabo’s ones. So I opened the shiny new /etc/netplan/01-netcfg.yaml and added my DNSes. Yaml is very intuitive to read, tough I’m still a little bit new on how to add stuff… The final result:
network: version: 2 renderer: networkd ethernets: eth0: match: macaddress: 00:x:x:x:x:3d addresses: - 173.x.x.x/24 - 2a02:x:x:x:x:x:x:0001/64 gateway4: 173.x.x.x gateway6: fe80::1 nameservers: search: [ invalid ] addresses: - 220.127.116.11 - 18.104.22.168 - 2606:4700:4700::1001 - 2001:4860:4860::8844
So now, how to update the system configuration? Restarting systemd-networkd.service didn’t help, so what?
The solution is to use netplan command!
Just running netplan apply will apply changes made to 01-netcfg.yaml! That’s it!
If you’re uncertain about what you did you can also run netplan try which will apply the configuration and roll it back in 120s if you don’t confirm it with a keypress! Super cool!
root@linux-host:~# netplan try Do you want to keep these settings? Press ENTER before the timeout to accept the new configuration Changes will revert in 113 seconds