HOME Software Lotus Cars DWARF Kindle Solar
graphic with lotus elise and lotus elan

Solar Power

Ubuntu Networking with Netplan

Every two years Ubuntu (and its derivatives) move to the next Long Term Stable release. For 2018 it is Ubuntu 18.04, named Bionic Beaver.

Every time, it seems, there is a new way to specify your simple local static ip setup and the old way no longer works.

For 2018 the new setup is called netplan, and it is automatically installed with the release. But when the system starts up NetworkManager (network-manager) is what is controlling your ip address, whether it is a fresh Ubuntu install or an upgrade to 18.04. I've always found network-manager a nightmare to work with.

Netplan is really simple to work with and I suspect you will find it so too. But some of the documentation you will find on the web is incomplete and/or wrong. So here is what actually works for my simple case. The ip addresses given are legitimate for a home or business internal NATed network but not what we actually use. We have about 20 machines of various sorts with static IP addresses (ipv4) and a small number that use dhcp from the router. It's as simple a setup as I could think of. The setup on a machine has to be done as root or via sudo, even we forget to say so below.

First, set up the control file. The /etc/netplan/ directory is most-likely empty (it was for me).

# File name /etc/netplan/99_config.yaml
# The particular machine is awarded ip .15 and
# the /24  automatically sets the netmasq to
# We don't use dhcp on this machine. It has a single
# wired ethernit port.
# The [] square brackets seem to be required and
# multiple addresses are allowed inside the [] separated
# by commas (though inappropriate for the simple setup
# described here).
  version: 2
  renderer: networkd
      dhcp4: no
      dhcp6: no
      addresses: []
        addresses: []

Now lets get NetworkManager out of the picture, break any /etc/resolv.conf symlink, and set up resolv.conf . NetworkManager will have generated resolv.conf in a useless way so we don't care about its content.

sudo systemctl stop    systemd-resolved.service 
sudo systemctl disable systemd-resolved.service
sudo systemctl stop    NetworkManager.service
sudo systemctl disable NetworkManager.service
sudo rm /etc/resolv.conf
# Here assuming you want to route dns queries
# via your router and let it pass the
# request on rather than naming some other
# valid nameserver ip address like or a
# nameserver ip provided by your ISP.
sudo echo "nameserver" >/etc/resolv.conf

In the Startup Applications panel off of the "Preferences" menu item, uncheck Network as that applies to Network Manager. In the networking panel of Preferences uncheck all general preferences. Those are for Network Manager, which we do not want to use.

Now edit /etc/hostname and /etc/hosts to ensure that the hostname is correct and lists the correct ip address in /etc/hosts . In /etc/hosts you can have multiple nicknames for each ip address if you wish.

# Example from /etc/hosts. Do not disturb other lines
# in /etc/hosts not relevant to the ip entry
# you want to add or change. machine15 machine15.home

Now we are ready to start up networking with netplan. As of this writing (September 6, 2018) there is still a bug in netplan that prevents it from working unless the machine is plugged into a live ethernet wire. So here we go:

sudo netplan apply

Yes, that's it. If there are any typos (surely there are :-) you will surely get a warning identifying the line in error and netplan will do nothing. Fix and retry the apply. When there is no output from the 'apply' your network is up and running the new way. Assuming (due to a bug in netplan) you remembered to plug a live ethernet cable into the ethernet port (that you mentioned in the netplan .yaml file) on the machine.

# To check things try the following commands 
# (as yourself, root permission not needed)
cat /etc/resolv.conf
#And this should work
ping -c 1 google.com
#And the following should show network-manager is off
#with a [ - ]  network-manager:
service --status-all

At this point networking is set up and you will likely want to restart the machine and recheck with ifconfig etc.

Happy Networking!

Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License.