Ubuntu

Setting Up Static IP Address on Ubuntu 22.04 LTS

Linux-based systems such as Ubuntu 22.04 offer two major options for configuring the network interfaces when it comes to IP addresses. You can either utilize DHCP to get an IP address automatically or set a Static IP Address that will never change. More specifically, setting Static IP address assists in granting someone remote access or in a situation when you want to host a web server.

This write-up will discuss the procedure of setting a Static IP address on Ubuntu 22.04 using two different methods. So, let’s start!

Set Static IP Address using nmcli command on Ubuntu 22.04

In the terminal, you can utilize the “nmcli” command to set up a Static IP Address on Ubuntu 22.04. The “nmcli” command enables Linux users to control the “NetworkManager”. It can be also used for printing the status of network device status, creating, modifying, deleting, activating, or deactivating network connections.

For setting up a Static IP Address using the “nmcli” command, follow the below-given step-by-step procedure.

Step 1: Check device name
Firstly, press “CTRL+ALT+T” to open up the terminal and then run the following “nmcli” command to check the device name:

$ nmcli connection show

The given output shows that our device name is “enp0s3”:

Step 2: Create a Static connection
In the next step, we will create a new static connection named “static ip” for the “enp0s3” device:

$ sudo nmcli con add type ethernet con-name 'static-ip' ifname enp0s3 ipv4.method manual ipv4.addresses 192.168.1.102/24 gw4 192.168.1.1

Step 3: Add DNS IP to static-ip
Then, execute the below-given command for adding the DNS IP to the “static-ip” connection:

$ sudo nmcli con mod static-ip ipv4.dns 192.168.1.1

Step 4: Activate the Static connection
Make sure that the created “static-ipconnection is active and working on your Ubuntu 22.04:

$ sudo nmcli con up id 'static-ip'

The below-given output indicates that our “static-ip” connection is successfully activated:

Step 5: Verify the IP assignment to the selected device
Now, execute the “ip” command with the “a” option to validate the IP assigned to the “enp0s3” device:

$ ip a

Lastly, verify the internet connectivity with the help of the following “ping” command:

$ ping google.com

As you can see, the given output validates that the configured “static-ip” connection is working perfectly:

Now, let’s check out the GUI method for setting up Static IP Address on Ubuntu 22.04.

Set Static IP Address using GUI on Ubuntu 22.04

Some Linux users prefer to utilize GUI instead of the terminal for the tasks related to network configuration. Are you one of them? If yes, then look at the below-given instructions for setting up a Static IP Address on Ubuntu 22.04 using GUI Network Settings.

First of all, click on the “network” icon that is present at the top-right side of your Ubuntu 22.04 desktop screen:

From the opened menu, select the “Wired Settings” option:

A Network Settings window will appear on your screen. Now, click on the “gear” icon that is located on the right side of your network connection:

Upon doing so, you will see the following dialog box:

Switch to the “IPv4” tab of the opened dialog box, select “Manual” as the “IPv4 Method” and then enter values for “Address”, “Network”, “Gateway” and “DNS”. After doing so, click on the “Apply” button:

In the next step, click on the highlighted “switch” to restart the network:

Lastly, verify the newly set configuration by clicking on the “gear” icon:

The above-given network connection details indicate that we have successfully set the Static IP Address on our Ubuntu 22.04 system.

Conclusion

On your Ubuntu 22.04 system, you can utilize the “nmcli” command in the terminal for setting a static IP Address. In the other case, you can configure a Static IP Address using the Network Settings of the selected Wired Connection. This write-up discussed the methods to set up a Static IP Address on Ubuntu 22.04.

About the author

Sharqa Hameed

I am a Linux enthusiast, I love to read Every Linux blog on the internet. I hold masters degree in computer science and am passionate about learning and teaching.