Network Configuration with Netplan on Ubuntu 18.04

With the version 18.04 (Bionic Beaver) Ubuntu has switched to Netplan for the configuration of network interfaces.

This is a YAML based configuration system, which simplifies the configuration process.

Configuration files

This new tool replaces the configuration file (/etc/network/interfaces) that had previously been used to configure the network interfaces on Ubuntu.
The configuration files are now located as YAML files at /etc/netplan/*.yaml. Make sure to respect the YAML standards when you edit the file as it might not work if there is a syntax error in your configuration.

A file 01-netcfg.yaml 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).
network:
  version: 2
  renderer: networkd
  ethernets:
    enp1s0f0:
      dhcp4: yes

Following you can see a list of the most common configuration options and a description of how they are used.

Option Example Description
addresses [192.168.1.2/24, 62.210.123.123/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

Configuration of a failover IP with Netplan

To configure a failover IP, you have to edit the file /etc/netplan/01-netcfg.yaml and configure a 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:

network:
  version: 2
  renderer: networkd
  ethernets:
    enp1s0f0:
      addresses: [163.172.123.123/24, 212.83.123.123/32]
      gateway4: 163.172.123.1
      nameservers:
        addresses: [ "62.210.16.6", "62.210.16.7" ]

Once you have edited and saved the file you can reload the configuration with the following command: sudo netplan apply

Configuration of a failover IP in a virtual machine

When you configure a failover IP inside a virtual machine, you have to specify the route that will be used by the VM. Your configuration file should look like in the following example:

network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      dhcp4: no
      dhcp6: no
      addresses: [fail.over.ip.address/32]
      gateway4: 62.210.0.1
      nameservers:
        addresses: [62.210.16.6, 62.210.16.7]
      routes:
      - to: 62.210.0.1/32
        via: fail.over.ip.address
        scope: link

Configuration of the RPN interface on a Dedibox

The primary network Interface of your Dedibox is configured automatically during the installation of the server.
To use the RPN with your server, you have to manually bring up the second interface.

Step 1 - Detect the network interface names of your server

The name of the network interfaces may be different from server to server, as it depends on the hardware configuration.
To detect the name of your RPN interface run ifconfig -a and check in the list of all interfaces which one corresponds to the RPN interface by comparing the MAC addresses (1). The name of the RPN interface will be shown in the list (2):

Step 2 - Configuration of the interfaces file

In our example, the RPN network interface is named enp1s0f1. We have to add this now to the file /etc/netplan/01-netcfg.yaml with a configuration via DHCP:

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

Once you have added the configuration save the file and reload the network configuration by running:

sudo netplan apply

Step 3 - Test the configuration

Once the new configuration has been activated, your server will obtain the RPN IP within some seconds from a DHCP server. You can verify the configuration by running ifconfig:

You notice that the Interface has obtained its RPN IP and you can test it by making a ping to san-1.rpn.online.net:

Configuration of the RPNv1 Gateway

Some services like the RPN-SAN are currently only available within the RPNv1 and to use them, you have to configure a RPNv1-Gateway to use them. You can request the RPNv1 subnet in your management console and edit add the VLAN for your RPN as following:

# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
  version: 2
  renderer: networkd
  ethernets:
    enp1s0f0:
      addresses: [ "163.172.123.123/24" ]
      gateway4: 163.172.123.1
      nameservers:
        addresses: [ "62.210.16.6", "62.210.16.7" ]
    enp1s0f1: {}
    
  vlans:
    vlan.2002:
        id: 2002
        link: enp1s0f1
        addresses: [ "10.88.109.228/28", "192.168.1.2/24" ]
        gateway4: 10.88.109.225
        routes:
          - to: 10.88.0.0/13
            via: 10.88.109.225
            on-link: true