How To Configure a Static IP on RHEL 8

Configuring a static IP address on RHEL 8 (Red Hat Enterprise Linux 8) is a fundamental networking task that ensures your server or system has a fixed IP address, which is crucial for seamless communication within a network. Unlike dynamic IP addresses assigned by DHCP, a static IP remains constant, making it ideal for servers, printers, or other devices that require consistent access. This guide will walk you through the steps to configure a static IP address on RHEL 8 using both the terminal and NetworkManager tools, ensuring your system is set up for reliable and efficient network performance.

Using nmcli To configure a Static IP Address​

Step 1: Show Available Network Interfaces​

Run the following command to display all available network interfaces:
[root@atiq ~]# nmcli connection show
NAME UUID TYPE DEVICE
ens160 e7d8560a-4538-406f-b3d2-c03a4996f6c1 ethernet ens160
In this example, the interface is ens160

Step 2: Modify the Network Interface Configuration​

Use the following command to set the static IP address, gateway, and DNS for the network interface:
[root@atiq ~]# nmcli connection modify ens160 \
ipv4.addresses 192.168.191.39/24 \
ipv4.gateway 192.168.191.1 \
ipv4.dns 8.8.8.8 \
ipv4.method manual \
connection.autoconnect yes

Step 3: Bring Up the Interface​

Activate the network interface to apply the new settings:
[root@atiq ~]# nmcli connection up ens160
nmcli is a command-line interface for NetworkManager, which can be used to obtain information or configure network interfaces.

Detailed Steps to Configure a Static IP Address​

Step 1: Set IPv4 Address​

To set the IPv4 address for a specific interface (e.g., enp0s3), use the following command:
# nmcli con mod enp0s3 ipv4.addresses 192.168.20.170/24

Step 2: Set the Gateway IP​

Specify the gateway IP address:
# nmcli con mod enp0s3 ipv4.gateway 192.168.20.1

Step 3: Enable Manual IP Configuration​

Inform the interface to use manual IP configuration instead of DHCP:
# nmcli con mod enp0s3 ipv4.method manual

Step 4: Set the DNS Server​

Add a DNS server IP address:
# nmcli con mod enp0s3 ipv4.dns "8.8.8.8"

Step 5: Reload the Interface Configuration​

# nmcli con up enp0s3

Apply the changes by reloading the network interface configuration:

Configuration File Overview

The changes made will be saved in the corresponding network configuration file under /etc/sysconfig/network-scripts/. You can verify the configuration using the following command:

# cat /etc/sysconfig/network-scripts/ifcfg-enp0s3

Sample Configuration File (ifcfg-enp0s3)

Below is an example of a generated configuration file:
TYPE="Ethernet"
BOOTPROTO="none"
NAME="enp0s3"
IPADDR="192.168.20.170"
NETMASK="255.255.255.0"
GATEWAY="192.168.20.1"
DEVICE="enp0s3"
ONBOOT="yes"
PROXY_METHOD="none"
BROWSER_ONLY="no"
PREFIX="24"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="no"
UUID="3c36b8c2-334b-57c7-91b6-4401f3489c69"

By following these steps, you can successfully configure a static IP address on RHEL 8, ensuring stable and reliable network connectivity for your system.
 
Last edited:

About us

  • oDiscuss Community provides a forum platform for discussing, sharing resources and ideas, and finding answers on various topics, including technology, IT, IT systems, networking systems, computers, servers, blogging, digital marketing, SEO, web design, web development, and more.

Quick Navigation

User Menu