Netplan – Networking – Ubuntu

Reading Time: < 1 minute

Last Update: 2/24/2022

As of Ubuntu 18.04 there is a new sheriff in town. Gone are the days of editing “interfaces” There is a new way of doing business.

The new configuration file uses a YAML file for configuration. It comes with a profiling tool to check your work as well as a tool to activate the change.

Remember this file should be stored in /etc/netplan
netplan uses a YAML style configuration.
A typical (early) default configuration had a name like: 01-netcfg.yaml

The default (early version) looked something like.

# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
  version: 2
  renderer: networkd
  ethernets:
    eno1:
      dhcp4: yes

A default early configuration would look something like.

network:
    version: 2
    renderer: networkd
    ethernets:
        eno1:
            addresses:
                - 172.16.104.250/24
            gateway4: 172.16.104.1
            nameservers:
                search: [sparelab.net]
                addresses: [8.8.8.8]

The following version of the config demonstrates the use of routes. The early version of the netplan configuration implemented a “gateway4:” example:

gateway4: 192.168.0.1

The named version of the config was named: 50-cloud-init.yaml

The most latest version of the config found in /etc/netplan is 00-installer-config.yaml

# This is the network config written by 'subiquity'
network:
  version: 2
  renderer: networkd
  ethernets:
    ens160:
      addresses:
      - 192.168.0.47/24
      nameservers:
        addresses:
        - 192.168.0.1
        search:
        - my.lab
      routes:
        - to: default
          via: 192.168.0.1

Oddly there is one thing that is not on the netplan page mentioned above.

sudo netplan try

When you are satisfied you can apply it with:

sudo netplan apply

UPDATE (8/22/2021):

As of Ubuntu 20.04 I don’t think netplan comes pre-installed. And just to show you how things can change they changed the package to “netplan.io”. Note: it appears that netplan uses python. So if your python environment is a bit janky or custom… netplan may not find all the dependent modules.

This entry was posted in Linux, Networking, Ubuntu. Bookmark the permalink.