[Tutorial]How to set a static IP address

While it may be obvious to some like myself that have been working with Linux for a while, others it may not be obvious how to set a static IP. So just in case you wanted to know, this is how you can do it from the console.

set a root password in case you have not yet.

At the console, set a root password if you have not done so.

hit alt-f2
login as root
run passwd-root

run the command:
nmcli connection show

You will get an output which looks like this:

Wired connection 1 <UUID> ethernet eth0
zt2oa3epmk <UUID> tun zt2oa3epmk
docker0 <UUID> bridge docker0
virbr0 <UUID> bridge virbr0

run the below commands replacing the IP address with the addresses you want to use:

nmcli con mod “Wired connection 1” ipv4.addresses “”
nmcli con mod “Wired connection 1” ipv4.gateway
nmcli con mod “Wired connection 1” ipv4.method manual
systemctl restart NetworkManager


to verify the new IP is assigned to the interface.

I usually reboot the system at this point to make sure the change is persistent between reboots.


Thanks you.

Will this survive updates?

Honestly I do not know.

As long as just packages are updated it should, however if the update overwrites the whole OS it may not and you will have to do it again.