How to Set Static IP Address on Ubuntu 22.04?

An IP address that remains the same is a Static IP address. We often have to deal with the dynamic IP address on Ubuntu (or any other system). The servers acquire the Static IP address to keep their identification the same over the network. To fulfill this, the Internet Service Providers (ISPs) dedicate a specific ID address to that customer (known as Static). Otherwise, the ISPs keep on changing the addresses (Dynamic IP Address) on every restart of the system (whenever a new connection is established).

The Static IP has shown a firm grip while establishing a remote connection, managing the connected devices, troubleshooting the network/device, and providing smooth communication, on Ubuntu and other Linux distros.

So, keeping the importance of Static IP address in view, this post will demonstrate the detailed methods alongside the steps to set the static IP address on Ubuntu 22.04.

How to Set the Static IP Address on Ubuntu 22.04?

The static IP address can be configured on Ubuntu 22.04 via the netplan utility, and the Network Manager (using the nmtui, nmcli, or the GUI). The nmcli and nmtui are used alternatively and have the same purpose (uses the Network Manager to manage the Static IP). Whereas the netplan acts differently from the listed utilities (uses the Networkd to manage Static IP address).


1. How to Set/Configure the Static IP Address Using netplan? | Ubuntu Server/Desktop

The netplan utility is the default network management tool for Ubuntu (after Ubuntu 17.10). The netplan has a configuration file with an extension “.yaml”. The “.yaml” contains the configurations set by the user (or by the system) which impacts your network accordingly.

Before setting up a Static IP address, let’s first check the IP address of the interface that you are going to change:

$ ip a

The “enp0s3” is the network interface having the IP address “”. The “Broadcast” in this case is “”, which is the last one on the network. So, the IP Address must be chosen between the “” and “”.

Step 1: Backup the YAML File

First, create the backup of the current configuration (File Location: “/etc/netplan/*.yaml”), which helps in dealing with errors in the future:

$ cp /etc/netplan/01-network-manager-all.yaml 01-network-manager-all.txt

Step 2: Configure the YAML File for the Static IP Address

The “.yaml” file by default might contain very short details as follows:

$ cat /etc/netplan/01-network-manager-all.yaml

As there is no network interface or IP address specified it states that the netplan is not managing the network’s configuration on our system.

  • What is Renderer in the YAML File?

The renderer represents which utility has to manage the network manager. The “networkd” is more suitable for the static IPs and “NetworkManager” is suitable for Dynamic connections (DHCP). Moreover, the “networkd” is managed through the command line whereas the NetworkManager can also be used via GUI as well. If the value is not set, then it would consider the “networkd” as the network configuration tool.

Step 3: Set the Static IP Address

Open the file in any editor (nano, vim, or gedit) and write the IP Address, Gateway, and DNS, as we did here:

In the configuration file:

  • Use the “networkd” as the renderer.
  • The enp0s3 denotes the network interface to be configured.
  • The IP address we chose is “” (Keeping an eye on the Broadcast IP Address, “”).
  • The DNS is set to “”(primary Google’s DNS) or “” (secondary) which switches you from your ISP to Google public DNS (which is open and anyone can use).
  • The gateway is set to “” through which the device communicates to the other computers in the network.

Note: In the case of DHCP, the DNS is provided by the ISP.

Step 3: Apply the Changes

Use the following netplan’s command to apply the changes in debug mode:

$ sudo netplan --debug apply

Note: If there is any warning, you will get it at the end of the above output.

Now, verify the change by checking the IP address of the interface “enp0s3”:

$ ip a

Note: If you have followed the method correctly and the IP address is not changed, then reboot your system to get the changes.


2. How to Set/Configure the Static IP Address Using nmcli? | Ubuntu Server/Desktop

NMCLI refers to the network manager’s command line interface, i.e., managing the network manager through the commands. Let’s see how the Static IP address is set up using the nmcli:

Identify the Network

Use the following nmcli command to get the device’s status:

$ sudo nmcli con show

The “Connection Name” (wired in our case) would be used in the nmcli to set/configure the Static IP Address. The “wired” connection is mapped with the device named “snp0s3”. Now, check the current IP address associated with the device named “enp0s3” using the command:

$ ip addr show

The interface is enp0s3 containing the IP address “” whereas the broadcast is “” (the range for the last number of the IP address to be set is 1-254).

Before proceeding further, the following are the details that will be set in the upcoming steps:

  • IP Address: | (as per our Broadcast ( we could choose between to
  • Gateway: | To send information to the other devices outside your network. It is usually set to the lowest IP range as per the broadcast (
  • DNS: | (Using Google’s public DNS, as we are choosing the IP address as per our own. If the static IP address is granted by your Internet Service Provider, the value might be changed (as it is granted by the ISP)).

Set the IP Address

Use the following nmcli command to set the IP address for the interface “enp0s3”(may be changed in your case), i.e., “”:

$ sudo nmcli con mod wired ipv4.addresses

Set the Gateway

$ sudo nmcli con mod wired ipv4.gateway

Set the DNS (Preferred is Google’s Public DNS)

$ sudo nmcli con mod wired ipv4.dns

Set the IPv4 configuration of enp0s3 to the Manual

$ sudo nmcli con mod wired ipv4.method manual

Activate the Connection

$ sudo nmcli con up wired

Verify the Newly Set IP

$ ip addr show

That’s how the nmcli tool can be used to set the static IP.


3. How to Set/Configure the Static IP Address Using nmtui? | Ubuntu Server/Desktop

NMTUI is an alternative to the nmcli utility. NMTUI manages the network manager through the text-based user interface on the terminal. Let’s exercise NMTUI to set/configure the Static IP:

First, check the current IP address of the connection that you are going to set to static:

$ ip a

Now, run the command “nmtui” from the terminal and the following interface appears. Choose “Edit a Connection”:

Select the connection and navigate to the “Edit” option:

Inside the edit mode, do the following:

  • 1: Set the IPv4 configuration to “Manual”.
  • 2: Select the “Show” option to get the fields where the IP address, gateway, etc to be written.
  • 3: Set the new IP Address (choose as per your broadcast, i.e.,
  • 4: Set the Gateway (as per your IP address/Broadcast, i.e.,
  • 5: Add the DNS (Google’s Primary DNS, i.e.,

Finally, scroll down and choose “OK”:

Fall back to the main menu of the NMTUI and “Deactivate/Activate” the connection:

Once done, verify the newly set IP address using the command:

$ ip a


4. How to Set/Configure the Static IP Address Using GUI? | Ubuntu Desktop Only

Open the Network Settings in Ubuntu 22.04 and then click on the “Settings” Gear

Note down the current “IPv4” address, i..e,”:


Navigate to the IPv4 on the toolbar and do the following:

  • Set/Change the IPv4 method to “Manual”.
  • Add the IP Address, Netmask, and the Gateway (IP Address and Gateway as per your broadcast).
  • Turn off the Toggle Button to set/change the DNS “Manual”.
  • Set the DNS (two addresses are added, one is Google’s primary DNS and the second is Google’s secondary DNS)
  • Lastly, click on Apply to make the changes effective.

Refresh the network connection and then verify the newly set IP address from the Details tab, as follows:

That’s how you set the static IP address on Ubuntu Desktop and Server.


Bottom Line

In Ubuntu, wherever the configurations are related to the IP addresses, the administrator does not want the network/IP settings/configurations to be changed frequently. That’s when the static IP address comes into practice. Mostly, the static IP address is granted by the Internet Service Provider. However, this post has explained the steps, of how a user can set the static IP address on Ubuntu 22.04.

The Ubuntu server/desktop supports the nmtui/nmcli and the netplan tools. However, the GUI-based support of Static IP is available on Ubuntu Desktop only. So, you have learned the ways to configure the static IP address on the Ubuntu server and desktop.

Print Friendly, PDF & Email