Ubuntu Server 20.04 LTS uses the tricky Netplan for network configuration by default. Network configuration is a bit more tricky, but still good. The default Netplan network configuration file on Ubuntu 20.04 LTS server is /etc/netplan/00-installer-config.yaml.

First, find the network interface name which you want to configure a static IP address with the following command:

$ ip a
ip a command output
ip a command output

As you can see my network interface name is eth0@if8, it will be different for you.

Now, you have to make sure that the network interface is not managed by CloudInit.

For that, open the configuration file with your favorite editor /etc/cloud/cloud.cfg.d/subiquity-disable-cloudinit-networking.cfg with the following command:

$ sudo vim /etc/cloud/cloud.cfg.d/subiquity-disable-cloudinit-networking.cfg

Make sure the configuration file contains the following line:

network: {config: disabled}

Now, open the Netplan configuration file using your favorite editor (I like using vim) /etc/netplan/00-installer-config.yaml with the following command:

sudo vim /etc/netplan/00-installer-config.yaml

To assign a static IP address to the network interface (in my case, your network interface name will be different) eth0@if8, remove everything from the Netplan configuration file /etc/netplan/00-installer-config.yaml and type in the following lines.

network:
  version: 2
  ethernets:
    eth0@if8:
      addresses: [192.168.1.160/24]
      gateway4: 192.168.1.2
      nameservers:
        addresses: [192.168.1.2, 8.8.8.8]

Now, to make sure that the configuration file does not have any syntax errors, run the following command:

sudo netplan try

If everything is good you should see a message with something like “Warning: stopping systemd-networkd.service, but it can still be activated by:…..Press ENTER before the timeout to accept the new configuration”

The new network configuration should be accepted. To make changes permanent run the following command:

sudo netplan apply

Double check the IP address run again:

ip a

Enjoy! Contact me if you have questions or leave a comment on the comments section below.

Leave a comment

Your email address will not be published. Required fields are marked *