How to setup static IP address on CentOS 8


When configuring servers, this is pretty often required in our line of work. Setting up a hosting server, router, load balancer, DNS server… These are everyday scenarios for most DevOps people to tackle around. In this light, we wanted to run through the process of setting up the static IP address on the CentOS 8 server.

Specification:

OS Version: CentOs 8.2 x64

Open nmtui command line tool for linux NetworkManager using the following command:

$ sudo nmtui

It will open options selection form:

nmtui options selector
nmtui options selector

We should choose the “Edit a connection” and hit ENTER. Next, we need to choose the interface. In our case that is the “System eth0“:

nmtui | interface selection
nmtui | interface selection

Hit ENTER and you’ll see the interface properties you can manipulate. From here, we need to edit the IPV4 section and add the IP addresses suiting your own scenario (we have used the IP addresses per our own use case):

nmtui | interface ipv4 details
nmtui | interface ipv4 details

Go down to <OK> and exit the nmtui tool. Now we just need to restart network service. We can do it by running the command:

$ sudo systemctl restart NetworkManager.service

NOTE: If you are performing this action on a remote server you MUST NOT use nmtui to restart interface/network! Using this tool you need to deactivate and then reactivate the interface which will cut you off of server!

That’s pretty much it! We have set the static IP address on CentOs 8 server 😁. You can verify the setting by using “ifconfig” command or similar:

$ ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 138.68.74.185 ...

Check out our EDU page for more useful articles 😁.

Share this post

Share this link via

Or copy link