Skip to main content

Setting a Static IP

Hands-On Lab


Photo of Michael Christian

Michael Christian

Course Development Director in Content





In this learning activity, you will take the DHCP assigned IP address and assign it as a static IP. This is an unforgiving exercise. If you misconfigure the IP address settings, you will need to restart the lab.

What are Hands-On Labs?

Hands-On Labs are scenario-based learning environments where learners can practice without consequences. Don't compromise a system or waste money on expensive downloads. Practice real-world skills without the real-world risk, no assembly required.

Setting a Static IP

The Scenario

In preparation for moving hardware to colocation, we're are being tasked with assigning hosts their dynamic IPs as static addresses.

Get logged in

Use the credentials and server IP in the hands-on lab overview page to log into our lab server. Once we're in, we can get moving.

Configure Static IPs

First let's see how things sit. We'll check our current networking situation like this:

[cloud_user@host]$ nmcli c

This will show us an interface, eth0. Let's dig a little further with:

[cloud_user@host]$ nmcli d show eth0

With that command, we've got all the details we need to run the actual configuration command. Substitute IP addresses with the correct ones from the last command:

[cloud_user@host]$ nmcli con mod System eth0 ipv4.method manual ipv4.addresses ipv4.gateway ipv4.dns ipv4.dns-search ec2.internal

Verify That the Address Is Now Set Manually, Not Dynamically

We'll run another command to verify. Look at the ipv4.method in the output from this:

[cloud_user@host]$ nmcli con show System eth0 | grep ipv4

Restart Networking

Finally, we've got to restart our network and make sure the changes stick:

[cloud_user@host]$ systemctl restart network


If we maintained connectivity, and another nmcli con show System eth0 | grep ipv4 shows the IP address we set, then we're done. Congratulations!