As you might have heard, Ubuntu (server) 18.04 uses a new network configuration system named Netplan.

Well, Netplan is not entirely new, it was introduced in Ubuntu 17:10 but I did not pay to much attention to it at the time because I prefer the Ubuntu LTS editions.

The first big change you will notice is the location the where the network configuration is stored. If you grab the default image form the Ubuntu website, there will be a file named “50-cloud-init.yaml” which is located in “/etc/netplan/”. The funny part is, this is not the only place you can store network configuration files. A blog post on the Ubuntu blog shows there are 3 locations available for storing network configurations (in order of importance):

  • /run/netplan/*.yaml
  • /etc/netplan/*.yaml
  • /lib/netplan/*.yaml

You can place any number of .yaml files in each of the above directory’s, where the lowest alphabetical filename will be the leading one (A*.yaml before B*.yaml). If a filename is used in multiple directory’s, the one in the most important directory will be the leading one.

Did I mention the files are YAML? Great lets use an indentation dependent format, what could possibly go wrong when using nano or VI without formatting and validation tools.

Needles to say, this might become a bit confusing when you need to troubleshoot a system you did not configure or maintain.

But enough of my ranting, lets she how we can configure a static IP address.

Luckily Canonical did set up a webpage to provide information about Netplan (https://netplan.io) this page also contains a neat set of Netplan examples.

The main page also explains that the default configuration location should be in “/etc/netplan/” there are no guidelines about the names for the configuration files, so you can “go ham” on those.

The configuration itself is kind of straight forward here is a basic IPv4 configuration with 2 name servers:

network:
  ethernets:
    eth0:
      addresses:
        - 192.168.0.2/24
      gateway4: 192.168.0.1
      nameservers:
          addresses: [192.168.0.1,8.8.8.8]

If you want IPv4 DHCP instead see below (for IPv6 set “dhcp6” to true and “dhcp4” to false):

network:
  version: 2
  ethernets:
    eth0:
      dhcp4: true
      dhcp6: false

Don’t forget to apply the configuration when your done

sudo netplan apply

If you need a more advanced configuration like more addresses on one interface or VLANs, check out the comprehensive example page on the Netplan website (https://netplan.io/examples).

They did a good job showing of a lot of differed possibility’s ­čÖé