How to configure a static IP address on CentOS 7 / RHEL 7

To configure a static IP address on CentOS 7 / RHEL 7, follow these steps:

  1. Open the network configuration file: Open the file “/etc/sysconfig/network-scripts/ifcfg-eth0” using a text editor. The “eth0” in the file name refers to the name of the network interface you want to configure. If you have multiple network interfaces, you will have multiple configuration files with different names.
  2. Update the network configuration: In the network configuration file, update the following settings to match your network requirements:
DEVICE=eth0
BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.1.100
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=8.8.8.8
DNS2=8.8.4.4
  • Replace “192.168.1.100” with the desired IP address for the network interface.
  • Replace “255.255.255.0” with the netmask for your network.
  • Replace “192.168.1.1” with the IP address of the gateway for your network.
  • Replace “8.8.8.8” and “8.8.4.4” with the IP addresses of the DNS servers you want to use.
  1. Save the network configuration file and restart the network: After making the changes, save the network configuration file and restart the network using the following commands:
# systemctl restart network
  1. Verify the IP address: To verify the IP address, run the following command:
# ip addr show eth0

The output should show the IP address, netmask, and other details for the network interface.

That’s it! You have now configured a static IP address on your CentOS 7 / RHEL 7 system.

Leave a Comment