Configuring Static IP Addresses on Ubuntu 17.10 Servers

Ubuntu 17.10 network configuration is completely changed. Have you heard of NetPlan? Probably not, but if you have, then you’re a step ahead of many. NetPlan is a new network configuration tool introduced in Ubuntu 17.10 to manage network settings.

It can be used by writing a simple YAML description of the required network interfaces with what they should be configured to do; and it will generate the required configuration for a chosen renderer tool.

This new tool replaces the static interfaces (/etc/network/interfaces) file that had previously been used to configure Ubuntu network interfaces. Now you must use /etc/netplan/*.yaml to configure Ubuntu interfaces.

This brief tutorial is going to show students and new users how to use NetPlan to set a static IP address on Ubuntu servers. This should be easy and quick.

The new interfaces configuration file now lives in the /etc/netplan directory. There are two renderers. NetworkManager and networkd.

NetworkManager renderer is mostly used on desktop computers and networkd on servers… If you want NetworkManager to control the network interfaces, use NetworkManager as the renderer, otherwise use networkd…

When you use NetworkManager as the renderer, you will use the NetworkManager GUI to manage the interfaces.

Below is a sample file for a network interface using networkd as renderer using DHCP…. Networkd uses the command line to configure the network interfaces.

# This file is generated from information provided by
# the datasource. Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
ethernets:
enp0s3:
addresses: []
dhcp4: true
version: 2

To save your changes, you run the commands below.

sudo netplan apply

Configuring Static IP Addresses with Networkd (Server)

To configure a static IP address using the new NetPlan tool on Ubuntu server, the file should look similar to the content below…

For example you might find a default netplan configuration file in the /etc/netplan directory called 50-cloud-init.yaml with a following content using the networkd deamon to configure your network interface via DHCP…..

sudo nano /etc/netplan/50-cloud-init.yaml

Then file should look like this one below:

# This file is generated from information provided by
# the datasource. Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
ethernets:
enp0s3:
addresses: []
dhcp4: true
version: 2

The above is a default networkd redenrer configuration file for a Ubuntu server using DHCP IP configuration…. If you want to setup a static IP address, configure the file as shown below

sudo nano /etc/netplan/50-cloud-init.yaml

Then configure IPv4 addresses as shown below… take notes of the format the lines are written…

What was wrong with using the /etc/network/interfaces file? Using YAML is the dumbest thing I’ve ever seen. I mean really…. this does not improve anything, and adds to the confusion. No we have to adhere to the stupid YAML format… counting spaces… counting spaces…. and counting more spaces…. dumb dumb dumb!

Generally I agree, however there were a lot of shortcomings in the /etc/network/interfaces methods, involving various hacks (policy based routing, bridge configuration, etc), and this (like systemd) is just another thing we have to swallow. At least there are benefits from this.

YAML is stupid as a human editable configuration file. It’s not as bad a json though.

How about if I want to configure nameservers while using dhcp configuration?

I am using ubuntucore.
I tried adding nameservers entry in the config file but that doesn’t seem to work. resolv.conf always gets overwritten on reboots. I disabled systemd-resolved and still no luck. updating any file (for example /etc/resolvconf/resolv.conf.d/base, /etc/dhcp/dhclient.conf) is also not possible since it’s a read-only file system.

How about setting 17.10 server with static wlan address ? I have managed to do configuration file without dns server, but when i add dns servers, it goes broken.. i really dont know where to put them and how.. resolv.conf works until next reboot ..

This change aligns with other industry standards – you may complain but down the track you will see the benefit unless you are narrow minded. Change happens always get use to it. Almost 30 years in the industry and I am still learning. Fantastic !

Sorry, you may not like XML but i’ts better for this kind of thing. yaml is not easy to catch spacing errors as their not visible.
Font’s will be critical when editing. yaml validator is an excellent tool, but it’s not available to offline systems.
And not easy to add as a software tool either.
I hope ubuntu considers making the validator a default tool on all installations if their sticking with it.
I vote to either go back or use XML.

If anyone is using mc and the internal edit feature of that program, do not use ‘tab’ for indents when creating your YAML file. This will result in an error when you try to apply the config. Instead, use spaces (single, double, triple, etc.). This may be obvious to some, but it caused me some grief.

Thank you for the write up. Only thing I found is for whatever reason, netplan did not like a the space in between my dsn severs, so just had to user a comma:
network:
ethernets:
eno3:
addresses: [172.22.7.175/22]
dhcp4: no
gateway4: 172.22.4.1
nameservers:
addresses: [8.8.8.8,172.22.0.16]
version: 2

Sometimes I feel like these bozos just like changing things for no other reason than to change them. I was just done getting pissed off over systemd-resolved, and now this.

Static text file configuration is one of the things I love about Linux. I feel like Ubuntu’s server edition hit the sweet spot with 14.04 LTS. Sure, it wasn’t pure init based, but upstart was way better than systemd, and ifupdown is key. Every release since has just been step after step in the wrong direction.

I have a bunch of servers still running 14.04 LTS I’ve been procrastinating updating. I may just move them to 16.04 LTS and stay there until support ends in 2021. If I do go with 18.04, I’ll probably wind up uninstalling netplan, and reinstalling ifupdown. I wish I could get rid of systemd-resolved too.

Long term I don’t know what the solution is. Even once conservative Debian has been making lots of stupid changes lately, so moving there is not really an option. Maybe it’s time to move to BSD? O_o