Hello folks, in this guide, we will cover how to set static ip address on Ubuntu 22.04 (Jammy Jellyfish) step by step.
There are two ways to configure static ip address on Ubuntu 22.04,
- Command line
- GUI (Desktop Environment)
From command line we use either nmcli or netplan command to set static ip address.
Set Static IP address using nmcli command
Open the terminal, run following nmcli commands.
To view the existing connection, run
$ nmcli connection show $ nmcli
As we can see above, my system has an existing connection named ‘Wired connection 1’ which is using physical nic ‘enp0s3’. In my case, this interface is getting IP address from DHCP server. So, to set the fixed static ip run,
Note: Replace the IP address and connection name as per your environment.
$ sudo nmcli con modify 'Wired connection 1' ifname enp0s3 ipv4.method manual ipv4.addresses 192.168.1.167/24 gw4 192.168.1.1
Add the DNS IP address,
$ sudo nmcli con mod 'Wired connection 1' ipv4.dns 192.168.1.1
Disable & enable the connection, run
$ sudo nmcli con down 'Wired connection 1' && sudo nmcli con up 'Wired connection 1'
Output of above commands would look like below:
Now this ip address is persistent across the reboot. To verify ip address run following ip commands,
$ ip add show $ ip route show
Alternate way to configure static ip address is via netplan utility.
Create ‘01-netcfg.yaml‘ under the directory /etc/netplan with following content,
$ sudo vi /etc/netplan/01-netcfg.yaml network: version: 2 renderer: networkd ethernets: enp0s3: #Change the interface name as per setup dhcp4: no addresses: - 192.168.1.167/24 routes: - to: default via: 192.168.1.1 metric: 100 nameservers: addresses: - 192.168.1.1 - 18.104.22.168
Save and close the file.
To make the above changes into the affect, run
$ sudo netplan appy
View the IP address, run
# ip address show
Perfect, above confirms that static ip address has been assigned to enp0s3 interface.
Setup Static IP address via GUI (Desktop Environment)
If you are not comfortable with command line, then you can set static ip address from desktop GUI.
From the Desktop Activity –>Search Settings –> Go to Network section
Click on the gearbox icon then following window will be shown. Select IPv4 Tab,
Change the IPv4 Method from Automatic to Manual. Specify the IP address details along with DNS IP.
Click on Apply to save the changes.
Now disable and enable the interface by toggling the icon.
Close the settings window and verify the ip address using following commands
That’s all from this guide, I hope you have found it informative. Kindly do post your feedback and queries in below comments section.