Jump toUpdate content
Network configuration with Netplan on Ubuntu
Since the release of its version 18.04, Bionic Beaver, Ubuntu has switched to Netplan for the configuration of network interfaces. It is a YAML based configuration system, which simplifies the configuration process.
This new tool replaces the
/etc/network/interfaces configuration file that had been previously used to configure the network interfaces on Ubuntu.
The configuration files are now located as YAML files in
Make sure you respect the YAML standards when you edit the file, as syntax errors might cause errors in your configuration.
01-netcfg.yaml file is used to configure the first interface. Below you can find the default configuration for an interface using DHCP:
# This file describes the network interfaces available on your system
# For more information, see netplan(5).
Following you can see a list of the most common configuration options and a description of how they are used.
|addresses||192.168.1.2/24, 126.96.36.199/32||A list of IP addresses to be assigned to an interface. The format uses CIDR notation.|
|gateway4||192.168.1.1||The IP address of your local IPv4 gateway.|
|dhcp4||true||Set whether DHCP is enabled for IPv4 – true of false|
|dhcp6||true||Set whether DHCP is enabled for IPv6 – true of false|
To configure a failover IP, you have to edit the file
/etc/netplan/01-netcfg.yaml and configure static networking for your server. The IP addresses have to be written with their CIDR notation. The netmask is
/24 for the principal IP of the server and
/32 for each failover IP. Your configuration file should look like in the following example:
addresses: [188.8.131.52/24, 184.108.40.206/32]
addresses: [ "220.127.116.11", "18.104.22.168" ]
Once you have edited and saved the file you can reload the configuration with the following command:
sudo netplan apply
When you configure a failover IP in a virtual machine, you have to specify the route that will be used by the VM. Your configuration file should look like the following example:
addresses: [22.214.171.124, 126.96.36.199]
- to: 188.8.131.52/32