How to Assign Static IP Address on Ubuntu 20.04 LTS

Channel: Linux
Abstract: let’s move to Ubuntu 20.04 LTS desktop. Assign Static IP Address on Ubuntu 20.04 LTS Desktop Network configuration in Ubuntu desktop is controlled by

It is always recommended to assign a static IP address to a Linux system because static ip address will be persistent across the reboots. Recently canonical has released its stable operating system 「Ubuntu 20.04 LTS (Focal Fossa)」 for both desktop and servers. In this article we will demonstrate how to assign a static ip address on Ubuntu 20.04 LTS Server and desktop.

Assign Static IP Address On Ubuntu 20.04 LTS Server

In Ubuntu 20.04 LTS server, network configuration is controlled and managed by netplan utility. But during the installation, cloud-init configure a dynamic ip to interface on server if the dhcp server is available. so, to configure a static ip, first we must make sure and confirm that network interface is not managed by cloud-init.

Open cloud-init file 「/etc/cloud/cloud.cfg.d/subiquity-disable-cloudinit-networking.cfg」 and make sure entry 「network: {config: disabled}」 is there. In case this entry is missing, then add it manually.

[email protected]:~$ cat /etc/cloud/cloud.cfg.d/subiquity-disable-cloudinit-networking.cfg
network: {config: disabled}
[email protected]:~$

Use 「ip addr show」 command from the console to view ip address,

[email protected]:~$ ip add show

As we can see above, a dynamic ip is assigned automatically on interface card 「enp0s3」. So, to make this ip address static, we must edit the netplan configuration file 「/etc/netplan/00-installer-config.yaml」.

[email protected]:~$ sudo vi /etc/netplan/00-installer-config.yaml
# This is the network config written by 'subiquity'
      dhcp4: true
  version: 2

Above are the default entries, which shows that interface 「enp0s3」 is getting the IP from DHCP server. As it is an yaml file, so while making the changes in the file we must follow correct indentation. Add the following lines to the yaml file,

      addresses: []
        addresses: [,]
  version: 2

save and close the file.

Run the following 「netplan apply」 command to make the above changes into the effect.

[email protected]:~$ sudo netplan apply
[email protected]:~$

Now run 「ip addr show」 and 「ip route show」 command to view ip address and route details.

[email protected]:~$ ip add show
[email protected]:~$ ip route show

Output of above command would look like below,

Perfect, output confirms that Static IP has been assigned successfully on interface ‘enp0s3‘. Even if we reboot the server, this ip address will be consistent.

Now, let’s move to Ubuntu 20.04 LTS desktop.

Assign Static IP Address on Ubuntu 20.04 LTS Desktop

Network configuration in Ubuntu desktop is controlled by network manager. Configuring a static ip address on Ubuntu 20.04 desktop is very easy. Login to your desktop environment and click on network icon and then choose wired settings.

In the next window, Click on ‘gear box’ icon under wired option,

In the next window, Choose IPV4 Tab and then select Manual and specify the IP details like IP address, netmask, gateway and DNS Server IP.

Click on Apply to save these changes and we must disable and enable interface once to assign the ip address to interface.

Once you enable and disable the interface then static IP should be assigned to the interface, we can verify by looking at the Details Tab from Wired Settings.

Perfect, above confirms that static ip address has been assigned to the interface successfully. This conclude the article; I hope these steps help you to configure static IP Address on your Ubuntu 20.04 LTS server and desktop. Please do share your feedback and comments.

Ref From: linuxtechi

Related articles