What is it
Netplan is a YAML network configuration abstraction for various backends (NetworkManager, networkd).
It is a utility for easily configuring networking on a system. It can be used by writing a YAML description of the required network interfaces with what they should be configured to do. From this description it will generate the required configuration for a chosen renderer tool.
Netplan reads network configuration from /etc/netplan/*.yaml which are written by administrators, installers, cloud image instantiations, or other OS deployments. During early boot it then generates backend specific configuration files in /run to hand off control of devices to a particular networking daemon.
The default renderer, if otherwise unspecified, is systemd-networkd.
How do I use it?
Netplan uses a set of subcommands to drive its behavior:
netplan generate: Use /etc/netplan to generate the required configuration for the renderers.
netplan apply: Apply all configuration for the renderers, restarting them as necessary.
netplan ifupdown-migrate: Attempt to generate an equivalent configuration to what is specified in /etc/network/interfaces.
Obviously, without configuration, netplan will not do anything. The most useful configuration snippet (to bring up things via dhcp) is as follows:
network: version: 2 renderer: NetworkManager
This will make NetworkManager manage all devices (and by default, any ethernet device will come up with DHCP once carrier is detected).
Using networkd as a renderer does not let devices automatically come up using DHCP; each interface needs to be specified in a file in /etc/netplan for its configuration to be written and for it to be used in networkd.
How do I bring interfaces up or down?
While we recommend that people do not change the state of network interfaces without a good reason and simply let the renderer configured in netplan handle the network interfaces it is meant to configure, you can always modify interface settings manually via the ip command.
To bring up an interface:
ip link set eth0 up
To bring and interface down:
ip link set eth0 down
See man ip for more information on how you can manipulate the state of network interfaces.
How can I look up the currently applied addresses for my system?
Netplan is only meant to translate configuration into the appropriate files for the backend you want to use. It does not display IP information by itself, since it does not manage those by itself.
You can always get the most accurate state of the IP addresses for your system using the ip addr command.
How do I configure a single interface with netplan so it works now and at next boot?
To achieve this you must write a simple netplan configuration file, such as this:
network: version: 2 renderer: networkd ethernets: eth0: dhcp4: true
Then save this to a file under /etc/netplan with a .yaml extension.
Finally, run netplan apply. This will enable DHCP on the eth0 interface, and immediately attempt to get a new IP address for it. Since the file is written to disk, the same rule will be applied at boot time.
To configure the interface for a static IP address, you could instead use:
network: version: 2 renderer: networkd ethernets: eth0: addresses: - 10.10.10.2/24 dhcp4: no
Simply write under addresses the IP address (IPv4 or IPv6) you want assigned to the interface, along with its prefix length. On many networks, /24 is the prefix length you want.
How do I unconfigure a single interface with netplan so it stops and remains unconfigured at next boot?
Simply remove the configuration for it. If the interface is not configured in a .yaml file in /etc/netplan, it will not be configured at boot.
To retain connectivity while you configure interfaces, IP addresses are not removed from interfaces when you run netplan apply. To remove addresses manually, you can use ip address del <address> dev <interface>.
How can I add pre-up, post-up, etc. hook scripts?
While the netplan configuration does not include support for hook scripts, you can add systemd unit jobs with the appropriate Requires: and After: fields to run arbitrary commands once the network is up.
I currently use Openvswitch ifupdown declarations and would like to replicate this on 18.04, how can I do that?
Openvswitch support requires the use of hook scripts. You would need to write a systemd unit that runs ovs_vsctl correctly for your particular setup.
#example systemd unit
I really do need ifupdown, can I still use it?
If you run into a case where you do need to use ifupdown instead of netplan, we would really like to know about it, so you should file a bug in Launchpad.
While we don't recommend doing so, you can remove netplan and install ifupdown after install, and fill in /etc/network/interfaces manually to configure your network the way you want it.
You can also opt to use ifupdown instead of netplan at installation by preseeding netcfg/do_not_use_netplan=true (adding it the the command-line when you boot the Ubuntu Server installation media, in grub (when you see the menu hit "e" to edit; or in the bootsplash by hitting F6). This will fallback to installing ifupdown and configuring it for the network devices set up during the installation.
Help for netplan is always available on Ubuntu systems through the man 5 netplan command.
Also, online HTML documentation is available here: http://people.canonical.com/~mtrudel/netplan/
Netplan developers are reachable on IRC on the Freenode network, in the channel #netplan.
How can I contribute?
Netplan is developed using git on Launchpad, and uses merge proposals.
You can find the source code here: https://code.launchpad.net/netplan
The main Launchpad project page is here: https://launchpad.net/netplan
We try to stick to an agreed-upon design document; see Netplan Design