How to configure a static IP address on RHEL 8

ww‮.w‬lautturi.com
How to configure a static IP address on RHEL 8

To configure a static IP address on Red Hat Enterprise Linux (RHEL) 8, you will need to perform the following steps:

  1. Open the network configuration file using your preferred text editor. For example:
sudo vi /etc/sysconfig/network-scripts/ifcfg-<interface>
  1. Find the following lines in the configuration file and edit them to reflect your desired static IP address, netmask, and default gateway:
IPADDR=<static IP address>
NETMASK=<netmask>
GATEWAY=<default gateway>
  1. Save the changes to the configuration file and exit the text editor.

  2. Restart the network service to apply the changes:

sudo systemctl restart network
  1. Verify that the static IP address has been correctly configured by using the ip command:
ip addr show <interface>

Alternatively, you can use the nmcli tool to configure a static IP address. To do so, follow these steps:

  1. Run the nmcli command with the connection and modify options, and specify the interface and the new IP address:
nmcli connection modify <interface> ipv4.addresses <static IP address>/<netmask>
  1. Set the default gateway:
nmcli connection modify <interface> ipv4.gateway <default gateway>
  1. Save the changes:
nmcli connection modify <interface> ipv4.method manual
  1. Restart the network service to apply the changes:
sudo systemctl restart network
  1. Verify that the static IP address has been correctly configured by using the ip command:
ip addr show <interface>
Created Time:2017-10-28 21:39:00  Author:lautturi