Ubuntu Server 22.04 uses a utility called ‘netplan’ for networking. To set a static IP we need to edit the config file.
In the terminal, go to the netplan config file location:
|
|
The file should be called 00-installer-config.yaml
. To edit it we need to run nano as root so we can make changes to it.
|
|
The static IP config should look similar to this:
|
|
eth0:
is the name of my network interface - yours may differ.- Under
addresses:
is the static IP to set, you’ll need to use CIDR notation, so/24
is255.255.255.0
. - DNS servers are configured under
nameservers:
multiple servers should be command separated. - The default gateway is set under
routes:
and- to: default
.
Save the file with CTRL + O and press enter to overwrite the existing file.
Exit with CTRL + X
To apply the changes run the following command:
|
|
To confirm the settings, run the following to see the current IP:
|
|
run the following to see the default gateway:
|
|
And now you know, and knowing is half the battle.
Support My Work
If you would like to support me, please check out the links below.
If you have any questions or comments please leave them below.
-Mike