For this week’s Bionic test blitz I am looking at Netplan! Netplan enables easily configuring networking on a system via YAML files. Netplan processes the YAML and generates the required configurations for either NetworkManager or systemd-network the system’s renderer.
Netplan replaced ifupdown as the default configuration utility starting with Ubuntu 17.10 Artful.
Configuration Link to heading
Initial Setup in Bionic Link to heading
When you install Bionic or use a cloud image of Bionic a file will appear in /etc/netplan
depending on the renderer in use. Here is a breakdown of the various types:
Install Type | Renderer | File |
---|---|---|
Server ISO | systemd-networkd | /etc/netplan/01-netcfg.yaml |
Cloud Image | systemd-networkd | /etc/netplan/50-cloud-init.yaml |
Desktop ISO | NetworkManager | /etc/netplan/01-network-manager-all.yaml |
Do note that configuration files can exist in three different locations with the precedence from most important to least as follows:
/run/netplan/*.yaml
/etc/netplan/*.yaml
/lib/netplan/*.yaml
Alphabetically later files, no matter what directory they are in, will amend keys if the key does not already exist and override previous keys if they do.
Examples Link to heading
The best method for demonstrating what netplan can do is by showing some examples. Keep in mind that these are very simple examples that do not demonstrate complex situations that netplan can handle.
Static and DHCP Addressing Link to heading
The following configures four devices:
- enp3s0 setup with IPv4 DHCP
- enp4s0 setup with IPv4 static with custom MTU
- IPv6 static tied to a specific MAC address
- IPv4 and IPv6 DHCP with jumbo frames tied to a specific MAC address
|
|
Bonding Link to heading
Bonding can easily be configured with the required interfaces list and by specifying the mode. The mode can be any of the valid types: balance-rr, active-backup, balance-xor, broadcast, 802.3ad, balance-tlb, balance-alb. See the bonding wiki page for more details.
|
|
Bridges Link to heading
Here is a very simple example of a bridge using DHCP:
|
|
Additional parameters can be passed in to turn off STP for example or set priorities.
Vlans Link to heading
Similarly, vlans only require a name as the key and then an id and link to use for the vlan:
|
|
Next Steps Link to heading
I was left with an overall very positive impression of netplan. Having the ability to write YAML configuration files and not have to worry about how the actual configuration was generated or what commands need to be used depending on the backend simplifies the process. I would like to continue to attempt some more complex configurations that I can find as well as attempt additional test cases with the ifupdown-migrate subcommand.