Thu. Feb 20th, 2020

Different Ways to Configure Static IP Address in RHEL 8

4 min read

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 Static IP address on RHEL 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 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 RHEL 8 server

[root@linuxtechi-rhel8 ~]# 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,

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

Use beneath nmcli command to assign static ip on enp0s3,


# nmcli connection modify ipv4.address 

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

Assign ipv4 ( to enp0s3 interface,

[root@linuxtechi-rhel8 ~]# nmcli con mod enp0s3 ipv4.addresses
[root@linuxtechi-rhel8 ~]#

Set the gateway using below nmcli command,

[root@linuxtechi-rhel8 ~]# nmcli con mod enp0s3 ipv4.gateway
[root@linuxtechi-rhel8 ~]#

Set the manual configuration (from dhcp to static),

[root@linuxtechi-rhel8 ~]# nmcli con mod enp0s3 ipv4.method manual
[root@linuxtechi-rhel8 ~]#

Set DNS value as “”,

[root@linuxtechi-rhel8 ~]# nmcli con mod enp0s3 ipv4.dns ""
[root@linuxtechi-rhel8 ~]#

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

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

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”

[root@linuxtechi-rhel8 ~]# cat /etc/sysconfig/network-scripts/ifcfg-enp0s3


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

[root@linuxtechi-rhel8 ~]#ip addr show enp0s3

Configure Static IP Address manually 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,

[root@linuxtechi-rhel8 ~]# cd /etc/sysconfig/network-scripts/
[root@linuxtechi-rhel8 network-scripts]# vi ifcfg-enp0s8

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

[root@linuxtechi-rhel8 network-scripts]# systemctl restart NetworkManager
[root@linuxtechi-rhel8 network-scripts]#

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

[root@linuxtechi-rhel8 ~]# ip add show enp0s8
3: enp0s8:  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
[root@linuxtechi-rhel8 ~]#

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

[root@linuxtechi-rhel8 ~]# 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

[root@linuxtechi-rhel8 ~]# ip add show enp0s3
2: enp0s3:  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
[root@linuxtechi-rhel8 ~]#

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 system. Please do not hesitate to share feedback and comments in comments section below.

More Stories

Leave a Reply

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

Copyright © All rights reserved. | Newsphere by AF themes.