In this article, I am going to show you how to set up a static IP address on Ubuntu Desktop 20.04 LTS and Ubuntu Server 20.04 LTS. So, let’s get started.

Network Configuration:

In order to configure a static IP on your computer, you need at least the IP address, the network mask, the gateway/default route address, and the DNS nameserver address.

In this article, I will use the following information,

IP Address: 192.168.20.160; Netmask: 255.255.255.0 or /24; Gateway/Default route address: 192.168.20.2; DNS nameserver addresses: 192.168.20.2 and 8.8.8.8

The information above would be different for you. So, make sure to replace them with yours as required.

Setting Up Static IP on Ubuntu Desktop 20.04 LTS:

Ubuntu Desktop 20.04 LTS uses Network Manager for network configuration. You can configure a static IP on Ubuntu Desktop 20.04 LTS graphically and from the command line. In this article, I will show you the graphical method of setting a static IP address on your Ubuntu Desktop 20.04 LTS.

To configure a static IP on your Ubuntu Desktop 20.04 LTS graphically, open the Settings app from the Application Menu.

Setting Up Static IP Address on Ubuntu 20.04 LTS Networking ubuntu

Now, go to Network.

Here, you should see all the available network interfaces of your computer. Click on the gear icon of the network interface which you want to configure a static IP address.

Setting Up Static IP Address on Ubuntu 20.04 LTS Networking ubuntu

A new window should open. In the Details tab, your current network configuration should be displayed.

Setting Up Static IP Address on Ubuntu 20.04 LTS Networking ubuntu

Now, go to the IPv4 tab. By default, IPv4 Method is set to Automatic (DHCP). Set it to Manual.

Setting Up Static IP Address on Ubuntu 20.04 LTS Networking ubuntu

A new Addresses field should be displayed.

Setting Up Static IP Address on Ubuntu 20.04 LTS Networking ubuntu

Type in your desired IPv4 address, netmask and gateway address.

Setting Up Static IP Address on Ubuntu 20.04 LTS Networking ubuntu

You can add multiple IP addresses to the same network interface. If you add multiple IP addresses to the same network interface, the IP addresses should have the same network gateway address.

Setting Up Static IP Address on Ubuntu 20.04 LTS Networking ubuntu

By default, DNS is set to Automatic. Click on the toggle button to disable Automatic DNS.

Setting Up Static IP Address on Ubuntu 20.04 LTS Networking ubuntu

Now, you can add DNS nameserver address here. If you have multiple DNS nameserver addresses, you can separate them with commas (,).

Setting Up Static IP Address on Ubuntu 20.04 LTS Networking ubuntu

Now, click on Apply to save the static IP information.

Setting Up Static IP Address on Ubuntu 20.04 LTS Networking ubuntu

The changes won’t be applied right away. You must restart your computer or the network interface for the changes to take effect.

To restart the network interface, click on the marked toggle button to turn the network interface OFF.

Setting Up Static IP Address on Ubuntu 20.04 LTS Networking ubuntu

Now, click on the marked toggle button to turn the network interface ON again.

Setting Up Static IP Address on Ubuntu 20.04 LTS Networking ubuntu

Now, click on the gear icon to confirm whether the new IP information is applied to the network interface.

Setting Up Static IP Address on Ubuntu 20.04 LTS Networking ubuntu

As you can see, the new IP information is applied to the network interface.

Setting Up Static IP Address on Ubuntu 20.04 LTS Networking ubuntu

So, this is how you set a static IP address on Ubuntu Desktop 20.04 LTS graphically using Network Manager.

Setting Up Static IP on Ubuntu Server 20.04 LTS:

Ubuntu Server 20.04 LTS uses Netplan for network configuration by default.

The default Netplan network configuration file on Ubuntu 20.04 LTS server is /etc/netplan/00-installer-config.yaml.

In this section, I am going to show you how to configure a static IP address on Ubuntu Server 20.04 LTS.

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

As you can see, the network interface name on my Ubuntu Server 20.04 LTS is ens33. The IP address 192.168.20.149 is assigned to the network interface ens33 currently.

The network interface name will be different for you. So, make sure to replace it with yours from now on.

Setting Up Static IP Address on Ubuntu 20.04 LTS Networking ubuntu

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

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

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

Setting Up Static IP Address on Ubuntu 20.04 LTS Networking ubuntu

Now, make sure the configuration file contains the following line.

network: {config: disabled}

Setting Up Static IP Address on Ubuntu 20.04 LTS Networking ubuntu

Now, open the Netplan configuration file /etc/netplan/00-installer-config.yaml with the following command:

$ sudo nano /etc/netplan/00-installer-config.yaml

Setting Up Static IP Address on Ubuntu 20.04 LTS Networking ubuntu

In the default Netplan configuration (as shown in the screenshot below), the available network interfaces (ens33 in my case) will be assigned IP addresses via DHCP.

Setting Up Static IP Address on Ubuntu 20.04 LTS Networking ubuntu

To assign a static IP address to the network interface ens33, remove everything from the Netplan configuration file /etc/netplan/00-installer-config.yaml and type in the following lines.

network:


version: 2


ethernets:


ens33:


addresses: [192.168.20.160/24]


gateway4: 192.168.20.2


nameservers:


addresses: [192.168.20.2, 8.8.8.8]

NOTE: Every line in a YAML configuration file must be indented correctly. Otherwise, Netplan will not accept the configuration file. You will see syntax error messages. Here, I have used 2 spaces for each level of indentation.

Once you’re done, save the configuration file by pressing X followed by Y and .

Setting Up Static IP Address on Ubuntu 20.04 LTS Networking ubuntu

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

Setting Up Static IP Address on Ubuntu 20.04 LTS Networking ubuntu

If everything is alright, you will see the following message. Press to continue.

Setting Up Static IP Address on Ubuntu 20.04 LTS Networking ubuntu

The new network configuration should be accepted.

Setting Up Static IP Address on Ubuntu 20.04 LTS Networking ubuntu

Now, to make the changes permanent, run the following command:

Setting Up Static IP Address on Ubuntu 20.04 LTS Networking ubuntu

Now, reboot your computer with the following command:

Setting Up Static IP Address on Ubuntu 20.04 LTS Networking ubuntu

Once your computer boots, the new network configuration should be applied as you can see in the screenshot below.

Setting Up Static IP Address on Ubuntu 20.04 LTS Networking ubuntu

So, this is how you configure a static IP address on Ubuntu Server 20.04 LTS. Thanks for reading this article.

About the author

Setting Up Static IP Address on Ubuntu 20.04 LTS Networking ubuntu

Shahriar Shovon

Freelancer & Linux System Administrator. Also loves Web API development with Node.js and JavaScript. I was born in Bangladesh. I am currently studying Electronics and Communication Engineering at Khulna University of Engineering & Technology (KUET), one of the demanding public engineering universities of Bangladesh.