Dynamic Host Configuration Protocol is commonly known as DHCP, used in the networking as a network protocol and it helps different devices to connect with a specific IP address. As the name is telling its dynamic so it changes and assigns different IP addresses to the devices which is very much helpful if we talk about the security of devices because it’s unable to access the IP address.
Sometimes we want the same IP address so in this write-up, we will change the DHCP of our machine to the permanent static IP address in Ubuntu.
How to change from DHCP to a static IP address on Ubuntu 22.04
To learn the method of changing from DHCP to a static IP address, first we have to find out the IP address of our machine which can find out by using the command:
$ ip a
We will open the networking tool of Ubuntu which is known as nmtui by using the command:
A menu of NetworkManager will be displayed from which we can choose the “Edit a connection”:
Now choose your connection and click on the “Add”:
The details of the connection are being displayed:
Change the mode of a configuration of IPv4 from “Automatic” to “Manual” using the command:
The settings have been changed from Automatic to Manual:
Now add the IP address you want to assign the machine with the Gateway address as well as DNS servers:
When you are done, scroll down the menu and click on the “Ok” button to save the settings:
Click on the “Back” to go back the menu:
Click on the “Activate a connection” to make it active:
Again click on “Activate”:
And click on the “Back” to save the settings:
Now Quit as the DHCP is changed to the static IP address:
In the terminal run the command to check the new assigned IP address:
$ ip a
Another approach to change the DHCP to static IP address is by going on the “Network” section in the Settings, and then click on the “Settings icon” next to the connected button:
Click on the “Manual” and insert the information of “Address”, “Netmask”, “Gateway”, and “DNS”:
Toggle the button off and then turn on to apply the new changes:
Again click on the setting icon to open the details of the network connection:
The changes have successfully been applied.
DHCP assigns and uses the dynamic IP addresses to the machine which are beneficial for security reasons but we can also change it to a static IP address by the two different methods which are discussed in this guide for Ubuntu 22.04.