On the other hand, a static IP refers to a fixed, immutable address, different from dynamic IPs. You can set static IP settings in Ubuntu 22.04 LTS and 22.10 in three different ways. Here’s how to get started.
Set a Static IP on Ubuntu With the nmcli Command
It is easy to set static IP settings in Ubuntu 22.04 using the nmcli command. nmcli is a text-based utility used to check the status of the wired connections you are using on your device.
With this command, you can access additional networking information such as your connection status, the name of your host device, and general permissions in your network configuration.
Follow the steps below to set a static IP address with the nmcli command.
You can get information about your connection with the following command:
The output of this command will be as follows:
Create a static link with the command below. Then, manually configure the enp0s3 and ipv4 settings with the appropriate parameters in the nmcli command.
If you use the nmcli connection show command again, you can see that the static link has been added.
After this process, add the static connection you created to the DNS IP.
Now use the command below to activate the connection:
If the output displays “connection successfully activated,” you’ve successfully set up a static IP address on your machine.
You can verify the static IP you want to assign to your device by running the following command:
Using Netplan for Static IP Settings on Ubuntu
Similar to nmcli, the netplan command allows you to set static IP settings on Ubuntu 22.04 LTS and 22.10. To do this, follow the steps below.
First, find out the name of your network interface using the command below:
What you see here is your network interface name. This name may be different on each device.
Now, create a file named 01-netcfg.yaml in the /etc/netplan folder. Edit it with your favorite text editor.
Add the following lines to the file:
As you can see, you have disabled the DHCP IP setting with the dhcp4: no statement. You’ve then added the IP address and DNS settings assigned by Google.
After saving this file, run the following command to apply the changes:
Configure Static IP Settings on Ubuntu Graphically
The graphical network settings interface in Ubuntu 22.04 is very useful if you don’t like to deal with the command line. You can set the static IP address you want using this interface.
To do this, click on the Network icon in the upper right corner of your desktop. Then, select Wired Settings from the drop-down menu. Click on the Gear icon to open the settings window.
Then, switch to the IPv4 tab in the window that opens.
As you can see, DHCP is enabled by default. Change the IPv4 Method to Manual as you want to use a static IP instead of a dynamic one. Next, change your address, netmask, and gateway settings. Finally, modify your DNS setting and click the Apply button.
You must restart this wired connection for all these actions to take effect. To do this, simply toggle the switch next to the network name on and then off.
Why Should You Use Static IP Addresses?
You learned how to configure static IP settings in “Jammy Jellyfish” 22.04, the latest LTS version of Ubuntu, and 22.10, using both the graphical settings interface and the two terminal commands: nmcli and netplan.
You can consider using static IP addresses to avoid connection problems caused by dynamic IP addresses. A static IP address allows you to have a fixed identity and location when connected to the internet.
Due to insufficient IP addresses, some service providers may assign the same address to two different users. In this case, connection problems can occur. Using static IP addresses instead does not cause such problems as it is user-specific.