How to configure static IP address on Ubuntu 22.04 LTS and 22.10
The IP addresses of most devices today are generated by the Dynamic Host Configuration Protocol (DHCP) server. The DHCP server dynamically assigns an IP address to your device when it is connected to the network. Therefore, you have the opportunity to change this IP address from time to time.
On the other hand, static IP refers to a fixed address, which cannot be changed, which is different from dynamic IP. You can set static IP settings for Ubuntu 22.04 LTS and 22.10 versions in 3 different ways.
Set static IP on Ubuntu using nmcli command
It's pretty easy to configure Ubuntu 22.04 static IP settings 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 network information such as connection status, host device name, and general permissions in the network configuration. Also, this command is useful in Ubuntu server static IP settings.
You can get information about your connection with the following command:
nmcli connection show
The output of this command will be as follows:
NAME UUID TYPE DEVICE Wired connection 1 12f312a7-f0e7-334a-8ab4-c7b3f8249c7e ethernet enp0s3
Create a static link with the command below. Then configure the enp0s3 and ipv4 settings manually with the appropriate parameters in the nmcli command:
sudo nmcli con add type ethernet con-name 'static' ifname enp0s3 ipv4.method manual ipv4.addresses 192.168.1.89/24 gw4 192.168.1.1
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:
sudo nmcli con mod static ipv4.dns 192.168.*.*
Now use the command below to enable the connection:
sudo nmcli con up id 'static'
If the output shows "connection enabled successfully" then you have successfully set up a static IP address on your machine.
You might consider using a static IP address 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.
You can verify the static IP you want to assign to your device by running the following command:
ip route
Using Netplan to Install Static IP on Ubuntu
Just like nmcli, another command that you can use to set a static IP on Ubuntu is netplan. You can easily do a static IP setup for Ubuntu using the netplan command in versions 22.04 LTS and 22.10. To do this, follow the steps below.
First find your network interface name with the command below:
sudo ip a
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 directory /etc/netplan. Edit it with your favorite text editor.
sudo vim /etc/netplan/01-netcfg.yaml
Add the following lines to the file:
network: version: 2 renderer: networkd ethernets: eth0: #Edit this line according to your network interface name. dhcp4: no addresses: - 192.168.1.10/24 gateway4: 192.168.1.1 nameservers: addresses: - 8.8.8.8 - 8.8.4.4
As can be seen, you have disabled the DHCP IP setting with the dhcp4: no command . Then you added the IP address and DNS settings specified by Google.
After saving this file, run the following command to apply the changes:
sudo netplan apply
Configure Static IP Settings on Ubuntu Using the GUI
The graphical interface in Ubuntu 22.04 is quite useful if you don't want to use the command line. So much so that you can easily set Ubuntu's static IP address using this interface.
To do this, click the Network icon in the upper right corner of the screen. Then, select Wired Settings from the drop-down menu. Click 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 IPv4 Method to Manual when you want to use static IP instead of dynamic IP. Next, change the address, netmask and gateway settings. Finally, modify the DNS settings and click the Apply button.
You must restart the 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.
You should read it
- What is a static IP address?
- How to assign static IP addresses in Windows 7, 8, 10, XP or Vista
- How to Configure a Static Internet Protocol (IP) Address on a Computer
- Display IP address on the system tray on Ubuntu
- Here's how to check if your IP address is static or dynamic
- Set up the Linksys router with a static IP address
- Static IP address or dynamic IP more secure?
- Set static IP settings for Windows XP, 7, 8, and 8.1 computers
- What's New in Ubuntu 21.10?
- How to configure static IP addresses on Linux
- What is static IP? What is dynamic IP? Distinguish between static IP and dynamic IP
- How to assign a static IP address in Windows 11, 10, 8, 7, XP or Vista
Maybe you are interested
How to use Canva's Magic Studio to edit designs How to read and write files using JES application Current Trends in Mobile App Development For 2022 Things to Keep in Mind Before Developing a Mobile App Avoid These Mistakes When Playing Situs Judi QQ Online Indonesia Great apps only available on Android