Ubuntu set static ip address using command line; Through this tutorial, we will learn how to set static ip address on linux ubuntu 22.04 system using command line or prompt.
How to Set Static IP Address in Ubuntu 22.04 Using Command Line
Steps to set static ip address in ubunut 22.04 using command line or terminal:
- Step 1 – Check device name
- Step 2 – Create a Static connection
- Step 3 – Add DNS IP to static-ip
- Step 4 – Activate the Static connection
- Step 5 – Verify the IP assignment to the selected device
Step 1 – Check device name
First of all open terminal or command line to check device name by using the following command:
nmcli connection show
The given output shows that our device name is “emp0s3”:
Step 2 – Create a Static connection
Use the following command to create a new static connection named “static ip” for the “emp0s3” device:
$ sudo nmcli con add type ethernet con-name 'static-ip' ifname emp0s3 ipv4.method manual ipv4.addresses 192.168.1.102/24 gw4 192.168.1.1
Step 3 – Add DNS IP to static-ip
Execute the following command to add 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
Execute the following command on command lien to active “static-ip” connection:
sudo nmcli con up id 'static-ip'
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
Then, verify the internet connectivity with the help of the following “ping” command:
ping google.com
Conclusion
Through this tutorial, we have learned how to set a static IP address on Linux ubuntu 22.04 system using the command line or prompt.