Ubuntu 18.04 introduced a new way to manage network interfaces configuration called Netplan When you upgrade a server though, the network configurator is not automatically replaced. If you want to replace it and use the new netplan configuration just follow the steps below (make sure you have another way to access your server if the network configuration fails):

  1. Install netplan.io package (it should already be installed in Ubuntu 18.04 and forward):

    sudo apt install netplan.io`
  2. Create the netplan configuration file according to your interfaces (refer to the docs if need be). By default, a fresh Ubuntu installation will create the file /etc/netplan/50-cloud-init.yaml, so we'll use it as a base:

    # This file is generated from information provided by
    # the datasource.  Changes to it will not persist across an instance.
    # To disable cloud-init's network configuration capabilities, write a file
    # /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
    # network: {config: disabled}
                - <your-ip-address>/<network-mask-CIDR>
                gateway4: <gateway-address>
                    - <nameserver1-address>
                    - <nameserver2-address>
                    - <search-domain-name>
        version: 2

    Just replace the fields to match your context.

    Note: Remember that this is a YAML file and the identation matters!

  3. Apply the netplan changes and verify everything worked:

    sudo netplan --debug apply

    Note: If you have previously defined network aliases (e.g. ens160:0, ens160:1) in your etc/network/interfaces file, you have to remove them prior to applying the netplan changes (a reboot may be in order too) because aliases are not supported in netplan and it will complain about it.

  4. Remove and purge the ifupdown package:

    sudo apt purge ifupdown
  5. Reboot the server

    sudo reboot

Your network interfaces should match the configured values defined in the netplan file:

ip addr show