HomeSys-AdminHow to Assign Static IP Address in Ubuntu 20.04

How to Assign Static IP Address in Ubuntu 20.04

This article explains a way tocreated a static information processing address on Ubuntu twenty.04.

Typically, in most network configurations, the information processing address is allotted dynamically by the router DHCP server. Setting a static information processing address is also needed in numerous thingslike configuring port forwarding or running a media server

Configure a Static IP address using DHCP 

The easiest and counseled way to assign a static information processing address to a tool on your computer network is to set up a Static DHCP on your router. Static DHCP or DHCP reservation could be a feature found on most routers that makes the DHCP server to mechanically assign a similar ip address to a selected network device, anytime the device requests associate address from the DHCP server. This works by distribution a static ip to the device’s distinctive mac address.

The steps for configuring a DHCP reservation vary from router to router. Consult the vendor’s documentation for a lot of data


Ubuntu 17.10 and later uses Netplan because the default network management tool. The previous Ubuntu versions were mistreatment ifconfig and its configuration file /etc/network/interfaces to piece the network.
Netplan configuration files ar written in YAML syntax with a .yaml file extension. To piece a network interface with Netplan, you would like to form a YAML description for the interface, and Netplan can generate the specified configuration files for the chosen renderer tool.
Netplan supports 2 renderers, NetworkManager and Systemd-networkd. NetworkManager is generally used on Desktop machines, whereas the Systemd-networkd is employed on servers while not a user interface.

Lets Configure the Static IP Address on Ubuntu Server

On Ubuntu 20.04, the system identifies network interfaces mistreatment ‘predictable network interface names’.

The first step toward fitting a static ip address is distinguishing the name of the LAN interface you wish to assemble. To do so, use the ip link command, as shown below:

$ ip link

The command prints a list of all the available network interfaces. In this example, the name of the interface is ens3:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
    link/ether 08:00:27:6c:13:63 brd ff:ff:ff:ff:ff:ff

Netplan configuration files square measurehold onwithin the /etc/netplan directory. You’ll most likelynotice one or additional YAML files during this directory. The name of the file mightdissent from setup to setup. Usually, the file is called either 01-netcfg.yaml, 50-cloud-init.yaml, or NN_interfaceName.yaml, however in your system it shouldvary.

If your Ubuntu cloud instance is provisioned with cloud-init, you’ll got to disable it. to try and do thus produce the subsequent file:

$ sudo nano /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg


$ network: {config: disabled}


To assign a static IP address on the network interface, open the YAML configuration file with your favorite text editor :

$ sudo nano /etc/netplan/01-netcfg.yaml


  version: 2
  renderer: networkd
      dhcp4: yes

Before ever-changing the configuration, let’s justify the code in a very short.

Each Netplan Yaml file starts with the network key that has a minimum of2neededpartsthe primaryneededpartis that the version of the network configuration format, and also thesecondis that the device kind. The device kindare often ethernets, bonds, bridges, or vlans.

The configuration on top of additionally encompasses a line that shows the renderer kind. Out of the box, if you put in Ubuntu in server mode, the renderer is designed to use networkd because the face.

Under the device’s kind (ethernets), you’ll specify one or a lot of network interfaces. during this example, we’ve gotjust one interface ens3 that’sdesignedto getip addressing from a DHCP server dhcp4: yes.

To assign a static scientific discipline address to ens3 interface, edit the file as follows:

Set DHCP to dhcp4: no.
Specify the static ip address. beneath addresses: you’ll add one or a lot ofipv4 or IPv6 IP addresses that may be assigned to the network interface.
Specify the entrance.
Under nameservers, set the scientific discipline addresses of the nameservers.


  version: 2
  renderer: networkd
      dhcp4: no
          addresses: [,]

When written material Yaml files, confirm you follow the YAML code indent standards. If the syntax isn’t correct, the changes won’t be applied.

Once done, save the file and apply the changes by running the subsequent command:

$ sudo netplan apply

Verify the changes by typing:

ip addr show dev ens3
2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 08:00:27:6c:13:63 brd ff:ff:ff:ff:ff:ff
    inet brd scope global dynamic ens3
       valid_lft 3575sec preferred_lft 3575sec
    inet6 fe80::5054:ff:feb0:f500/64 scope link 
       valid_lft forever preferred_lft forever

Great You Have Assined The Static IP Address On Your Ubuntu Server

Lets Configure the Static IP Address on Ubuntu Desktop

Setting up a static ip address on Ubuntu Desktop computers needs no technical data.

In the Activities screen, look for “settings” and click on on the icon. this can open the GNOME settings window. betting on the interface you wishto switch, click either on the Network or Wi-Fi tab. To open the interface settings, click on the cog icon next to the interface name.

In “IPV4” Method” tab, choose “Manual” and enter your static ip address, Netmask and entranceway. Once done, click on the “Apply” button.

To verify the changes, open your terminal either by using the Ctrl+Alt+T keyboard shortcut or by clicking on the terminal icon and run:

$ ip addr

The output will show the interface IP address:

2: wlp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 50:5b:c2:d8:59:7d brd ff:ff:ff:ff:ff:ff
    inet brd scope global dynamic noprefixroute wlp1s0
       valid_lft 38963sec preferred_lft 38963sec
    inet6 fe80::45e3:7bc:a029:664/64 scope link noprefixroute 

Wrapping Up

We’ve shown you how to configure a static IP address on Ubuntu 20.04.

If you have any questions, please leave a comment below.



Please enter your comment!
Please enter your name here

Most Popular

Recent Comments