To configure a static IP address on CentOS 7 or RHEL 7, you can follow these steps:
Open the network configuration file for the interface you want to configure. For example, to configure the eth0
interface, you can open the /etc/sysconfig/network-scripts/ifcfg-eth0
file.
Find the BOOTPROTO
line in the file and change the value to none
. This will disable DHCP and allow you to configure a static IP address.
Find the IPADDR
line in the file and set it to the desired static IP address. For example:
IPADDR=192.168.0.100
NETMASK
line in the file and set it to the appropriate subnet mask. For example:NETMASK=255.255.255.0
GATEWAY
line in the file and set it to the appropriate default gateway. For example:GATEWAY=192.168.0.1
Save the file and exit.
Restart the network service to apply the changes. You can use the following command:
systemctl restart network
This will apply the changes and set the static IP address for the specified interface.
It's important to note that you may need to have root privileges to edit the network configuration files and restart the network service.
For more information about configuring a static IP address on CentOS 7 or RHEL 7, you can refer to the documentation or use the --help
option with the ifconfig
and ip
commands. For example:
man ifconfig
man ip
ifconfig --help
ip --help