Ubuntu 18.04: changing network configuration

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:

  version: 2
  renderer: networkd
        macaddress: 00:x:x:x:x:3d
        - 173.x.x.x/24
        - 2a02:x:x:x:x:x:x:0001/64
      gateway4: 173.x.x.x
      gateway6: fe80::1
        search: [ invalid ]
          - 2606:4700:4700::1001
          - 2001:4860:4860::8844

I’m using a mix of Cloudflare’s, FreeDNS.zone and Google DNS.

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

Lascia un commento

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *

Solve : *
2 + 5 =

Questo sito usa Akismet per ridurre lo spam. Scopri come i tuoi dati vengono elaborati.