Skip to main content

Your submission was sent successfully! Close

Thank you for signing up for our newsletter!
In these regular emails you will find the latest updates from Canonical and upcoming events where you can meet our team.Close

Thank you for contacting us. A member of our team will be in touch shortly. Close

  1. Blog
  2. Article

Mathieu Trudel-Lapierre
on 5 July 2017

Quick and easy network configuration with Netplan


Earlier this week I uploaded netplan 0.21 in artful, with SRUs in progress for the stable releases. There are still lots of features coming up, but it’s also already quite useful. You can already use it to describe typical network configurations on desktop and servers, all the way to interesting, complicated setups like bond over a bridge over multiple VLANs…

Getting started

The simplest netplan configuration might look like this:

# Let NetworkManager manage all devices on this system
network:
  version: 2
  renderer: NetworkManager

At boot, netplan will see this configuration (which happens to be installed already on all new systems since 16.10) and generate a single , empty file: /run/NetworkManager/conf.d/10-globally-managed-devices.conf. This tells the system that NetworkManager is the only renderer for network configuration on the system, and will manage all devices by default.

Working from there: a simple server

Let’s look at it on a hypothetical web server; such as for my favourite test: www.perdu.com.

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

This incredibly simple configuration tells the system that the eth0 device is to be brought up using DHCP4. Netplan also supports DHCPv6, as well as static IPs, setting routes, etc.

Building up to something more complex

Let’s say I want a team of two NICs, and use them to reach VLAN 108 on my network:

            network:
              version: 2
              ethernets:
                eth0:
                  dhcp4: n
                eth1:
                  mtu: 1280
                  dhcp4: n
              bonds:
                bond0:
                  interfaces:
                  - eth1
                  - eth0
                  mtu: 9000
              vlans:
                bond0.108:
                  link: bond0
                  id: 108

I think you can see just how simple it is to configure even pretty complex networks, all in one file. The beauty in it is that you don’t need to worry about what will actually set this up for you.

A choice of backends

Currently, netplan supports either NetworkManager or systemd-networkd as a backend. The default is to use systemd-networkd, but given that it does not support wireless networks, we still rely on NetworkManager to do just that.

This is why you don’t need to care what supports your config in the end: netplan abstracts that for you. It generates the required config based on the “renderer” property, so that you don’t need to know how to define the special device properties in each backend.

As I mentioned previously, we are still hard at work adding more features, but the core is there: netplan can set up bonds, bridges, vlans, standalone network interfaces, and do so for both static or DHCP addresses. It also supports many of the most common bridge and bond parameters used to tweak the precise behaviour of bonded or bridged devices.

Coming up…

I will be adding proper support for setting a “cloned” MAC on a device. I’m reviewing the code already to do this, and ironing out the last issues.

There are also plans on better handling administrative states for devices; along with a few bugs that relate to support MaaS, where having a simple configuration style really shines.

I’m really excited for where netplan is going. It seems like it has a lot of potential to address some of the current shortcomings in other tools. I’m also really happy to hear of stories of how it is being used in the wild, so if you use it, don’t hesitate to let me know about it!

This post originally appeared on Mathieu Trudel-Lapierre’s blog

Related posts


Lukas Märdian
5 April 2024

Introducing Netplan v1.0 – stable, declarative network management

Cloud and server Article

After more than 7 years of development, Netplan v1.0 delivers improved stability and maintainability alongside a host of other new features. ...


Lukas Märdian
14 November 2023

Netplan brings consistent network configuration across Desktop, Server, Cloud and IoT

Cloud and server Article

Learn how Netplan has established itself as the proven network stack across all variants of Ubuntu – Server, Cloud, Embedded and now Desktop. ...


Netplan by default in 17.10

Ubuntu Article

Recently, I uploaded an updated nplan package (version 0.24) to change its Priority: field to important, as well as an update of ubuntu-meta (following a seeds update), to replace ifupdown with nplan in the minimal seed. What this means concretely is that nplan should now be installed by default on all images, part of ubuntu-minimal, ...