On Ubuntu 22.04 LTS, how to set up a static IP address

We independently review everything we recommend. When you buy through our links, we may earn a commission.

On Ubuntu 22.04 “Jammy Jellyfish,” it is simple to switch from dynamic IP allocation to the assignment of static IP addresses.

The Dynamic Host Configuration Protocol (DHCP) server is responsible for assigning the IP address to the majority of devices in use today. When your device is connected to a network, a DHCP server will provide it with a dynamic Internet Protocol address. As a result, you have the option of changing your IP address from time to time if you like.

A static IP address, on the other hand, is one that is fixed and cannot be changed, as opposed to a dynamic IP address. There are three alternative methods for configuring static IP settings in Ubuntu 22.04 LTS. Here’s everything you need to know to get started.

Set a Static IP on Ubuntu With the nmcli Command

Using the nmcli command, you may quickly and easily configure Ubuntu 22.04 to use static IP settings. A text-based program known as nmcli may be used to determine the status of any wired connections that are currently being utilized on your device.

You may use this command to gain access to more networking information, such as the state of your connection, the name of your host device, and the general permissions in your network setup, through your network settings.

To assign a permanent Internet Protocol address using the nmcli command, follow the instructions below.

By using the following command, you will be able to obtain information on your connection:

nmcli connection show

The following will be displayed as a result of carrying out this command:

Wired connection 1 12f312a7-f0e7-334a-8ab4-c7b3f8249c7e ethernet enp0s3

Using the command that is below, you may create a static link. The following step is to manually setup the enp0s3 and ipv4 settings in the nmcli command using the necessary parameters.

sudo nmcli con add type ethernet con-name ‘static’ ifname enp0s3 ipv4.method manual ipv4.addresses gw4

Using the nmcli connection display command again, you will be able to see that the static link has been added.

After you have completed this step, you should add the static connection you generated to the DNS IP address.

sudo nmcli con mod static ipv4.dns 192.168.*.*

Now, to activate the connection, run the command shown below:

sudo nmcli con up id ‘static’

You have successfully set up a static IP address on your system if the report displays “connection successfully enabled.”

By executing the following command, you will be able to check the static IP address that you intend to assign to your device:

ip route

Using Netplan for Static IP Settings on Ubuntu

The netplan command, which is similar to the nmcli command, allows you to configure static IP settings on Ubuntu 22.04 LTS. To accomplish this, please follow the instructions outlined below.

To begin, use the command that is provided below to get the name of your network interface:

sudo ip a

The name of your network interface may be found in this section. On many devices, this name may appear in a different format.

Now, create a new file in the /etc/netplan folder and give it the name 01-netcfg.yaml. Use whichever text editor you like to make the necessary changes.

sudo vim /etc/netplan/01-netcfg.yaml

Include the lines that are listed below in the file:

version: 2
renderer: networkd
eth0: #Edit this line according to your network interface name you just saw.
dhcp4: no

It is clear that you have turned off the DHCP IP option by include the dhcp4: no statement in your code. After that, you will have inserted the IP address as well as the DNS settings that were provided by Google.

After saving this file, you will need to implement the modifications by running the following command:

sudo netplan apply

Configure Static IP Settings on Ubuntu Graphically

If you prefer not to work with the command line, the graphical network settings interface that is included in Ubuntu 22.04 is an excellent alternative. Utilizing this interface, you are able to specify the static IP address that you choose.

To accomplish this, navigate to the upper right hand corner of your desktop and click on the symbol that looks like a network. The next step is to pick Wired Settings from the option that drops down. To access the settings window, you may open it by clicking on the Gear symbol.

set up Static IP Ubuntu Graphically

After that, in the new window that has opened, navigate to the IPv4 tab.

switch to the IPv4 tab on

As can be seen, the DHCP service is turned on automatically. Change the IPv4 Method to Manual if you wish to utilize a static IP address rather than a dynamic one, as described above. The next step is to modify the settings for your address, netmask, and gateway. In the end, you should change the DNS setting and then click the Apply button.

In order for all of these changes to take effect, you will need to restart this wired connection. To accomplish this, just turn on and then off the switch that is located next to the name of the network.

Configure Static IP Settings Ubuntu

Why Should You Use Static IP Addresses?

You were shown how to establish static IP settings in Ubuntu 22.04 “Jammy Jellyfish” by using both the graphical settings interface and the two terminal commands known as nmcli and netplan. Ubuntu 22.04 is the most recent version of the LTS distribution.

If you want to avoid connection issues that are caused by dynamic IP addresses, you might want to think about adopting static IP addresses instead. When you are connected to the internet, having a static IP address gives you the ability to maintain a consistent identity and location.

As a result of a shortage of IP addresses, certain service providers may find it necessary to allocate the same address to more than one customer. In this scenario, there is a possibility of connectivity issues. If you utilize static IP addresses instead of dynamic ones, you won’t run into the same issues because they are user-specific.

We will be happy to hear your thoughts

Leave a reply