How to Configure Static IP Address in RHEL 8 / CentOS 8

While Working on Linux Servers, assigning Static IP address on NIC / Ethernet cards is one of the common tasks that every Linux engineer do. If one configures the Static IP address correctly on a Linux server then he/she can access it remotely over network. In this article we will demonstrate what are different ways to assign or configure Static IP address on RHEL 8 / CentOS 8 Server’s NIC.

Following are the ways to configure Static IP on a NIC,

  • nmcli (command line tool)
  • Network Scripts files(ifcfg-*)
  • nmtui  (text based user interface)

Configure Static IP Address using nmcli command line tool

Whenever we install RHEL 8 / CentOS 8 server then ‘nmcli’, a command line tool is installed automatically, nmcli is used by network manager and allows us to configure static ip address on Ethernet cards.

Run the below ip addr command to list Ethernet cards on your server

[[email protected] ~]# ip addr


As we can see in above command output, we have two NICs enp0s3 & enp0s8. Currently ip address assigned to the NIC is via dhcp server.

Let’s assume we want to assign the static IP address on first NIC (enp0s3) with the following details,

  • IP address =
  • Netmask =
  • Gateway=
  • DNS =

Run the following nmcli commands one after the another to configure static ip,

List currently active Ethernet cards using “nmcli connection” command,

[[email protected] ~]# nmcli connection
NAME    UUID                                  TYPE      DEVICE
enp0s3  7c1b8444-cb65-440d-9bf6-ea0ad5e60bae  ethernet  enp0s3
virbr0  3020c41f-6b21-4d80-a1a6-7c1bd5867e6c  bridge    virbr0
[[email protected] ~]#

Use beneath nmcli command to assign static ip on enp0s3,


# nmcli connection modify <interface_name> ipv4.address  <ip/prefix>

Note: In short form, we usually replace connection with ‘con’ keyword and modify with ‘mod’ keyword in nmcli command.

Assign ipv4 ( to enp0s3 interface,

[[email protected] ~]# nmcli con mod enp0s3 ipv4.addresses
[[email protected] ~]#

Set the gateway using below nmcli command,

[[email protected] ~]# nmcli con mod enp0s3 ipv4.gateway
[[email protected] ~]#

Set the manual configuration (from dhcp to static),

[[email protected] ~]# nmcli con mod enp0s3 ipv4.method manual
[[email protected] ~]#

Set DNS value as “”,

[[email protected] ~]# nmcli con mod enp0s3 ipv4.dns ""
[[email protected] ~]#

To save the above changes and to reload the interface execute the beneath nmcli command,

[[email protected] ~]# nmcli con up enp0s3
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/4)
[[email protected] ~]#

Above command output confirms that interface enp0s3 has been configured successfully.Whatever the changes we have made using above nmcli commands, those changes is saved permanently under the file “etc/sysconfig/network-scripts/ifcfg-enp0s3”

[[email protected] ~]# cat /etc/sysconfig/network-scripts/ifcfg-enp0s3


To Confirm whether IP address has been to enp0s3 interface use the below ip command,

[[email protected] ~]#ip addr show enp0s3

Configure Static IP Address using network-scripts (ifcfg-) files

We can configure the static ip address to an ethernet card using its network-script or ‘ifcfg-‘ files. Let’s assume we want to assign the static ip address on our second Ethernet card ‘enp0s8’.

  • IP=
  • Netmask / Prefix = 24
  • Gateway=
  • DNS1=

Go to the directory “/etc/sysconfig/network-scripts” and look for the file ‘ifcfg- enp0s8’, if it does not exist then create it with following content,

[[email protected] ~]# cd /etc/sysconfig/network-scripts/
[[email protected] network-scripts]# vi ifcfg-enp0s8

Save and exit the file and then restart network manager service to make above changes into effect,

[[email protected] network-scripts]# systemctl restart NetworkManager
[[email protected] network-scripts]#

Now use below ip command to verify whether ip address is assigned to nic or not,

[[email protected] ~]# ip add show enp0s8
3: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 08:00:27:7c:bb:cb brd ff:ff:ff:ff:ff:ff
    inet brd scope global noprefixroute enp0s8
       valid_lft forever preferred_lft forever
    inet6 fe80::a00:27ff:fe7c:bbcb/64 scope link
       valid_lft forever preferred_lft forever
[[email protected] ~]#

Above output confirms that static ip address has been configured successfully on the NIC ‘enp0s8’

Configure Static IP Address using ‘nmtui’ utility

nmtui is a text based user interface for controlling network manager, when we execute nmtui, it will open a text base user interface through which we can add, modify and delete connections. Apart from this nmtui can also be used to set hostname of your system.

Let’s assume we want to assign static ip address to interface enp0s3 with following details,

  • IP address =
  • Prefix = 24
  • Gateway=
  • DNS1=

Run nmtui and follow the screen instructions, example is show

[[email protected] ~]# nmtui


Select the first option ‘Edit a connection‘ and then choose the interface as ‘enp0s3’


Choose Edit and then specify the IP address, Prefix, Gateway and DNS Server ip,


Choose OK and hit enter. In the next window Choose ‘Activate a connection


Select enp0s3,  Choose Deactivate & hit enter


Now choose Activate & hit enter,


Select Back and then select Quit,


Use below IP command to verify whether ip address has been assigned to interface enp0s3

[[email protected] ~]# ip add show enp0s3
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 08:00:27:53:39:4d brd ff:ff:ff:ff:ff:ff
    inet brd scope global noprefixroute enp0s3
       valid_lft forever preferred_lft forever
    inet6 fe80::421d:5abf:58bd:c47e/64 scope link noprefixroute
       valid_lft forever preferred_lft forever
[[email protected] ~]#

Above output confirms that we have successfully assign the static IP address to interface enp0s3 using nmtui utility.

That’s all from this tutorial, we have covered three different ways to configure ipv4 address to an Ethernet card on RHEL 8 / CentOS 8 system. Please do not hesitate to share feedback and comments in comments section below.

Read AlsoHow to Install and Configure Nagios Core on CentOS 8 / RHEL 8

5 Responses

  1. Scott says:

    The ip tool can be used to add and remove connections, bridges, addresses, etc.

  2. Pradeep Kumar says:

    Hi Scott,

    Yes, IP tool can be used to assigned the ip address but it will not persistent across the reboot.

  3. Xavi Aznar says:

    Thank you!

    Very good article!

    Best regards!


  4. Sumon Paul says:

    It’s so usefull.
    here have lot of content and very easy ways this content and solution.

    Thank You

  5. Mauro says:

    Very good. This article helped me a lot

Leave a Reply

Your email address will not be published. Required fields are marked *

Pin It on Pinterest