6/21/2021 How to Configure CentOS 7 Network Settings - Serverlab
Configuring a Static IP
A static address is one that is permanently assigned to one host. It is an address that is manually
configured by the administrator.
. Open the configuration file for your network interface.
vi /etc/sysconfig/network-scripts/ifcfg-eth0
. Add the following settings to the file:
DEVICE=enp3s0
ONBOOT=yes
IPADDR=192.168.1.10
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
. Save your changes and exit
. Your new settings will not apply until the network interface is restarted or brought online. If you are
remotely logged into the server and modifying the network settings of the interface you are
connected to, reboot the system.
. Restarting the network interface.
ifdown enp0s3
ifup enp0s3
Configuring DHCP Settings
A dynamic address is one leased from a DHCP server when a system boots or a network interface
comes online. The following settings configure a network interface for DHCP.
. Open the configuration file for your network interface.
vi /etc/sysconfig/network-scripts/ifcfg-
https://www.serverlab.ca/tutorials/linux/administration-linux/how-to-configure-centos-7-network-settings/ 1/2
6/21/2021 How to Configure CentOS 7 Network Settings - Serverlab
. Add the following settings. If a configuration already exists, modify it to look like the following:
DEVICE=enp3s0
ONBOOT=yes
DHCP=yes
. Save your changes and exit
. Your new settings will not apply until the network interface is restarted or brought online. If you are
remotely logged into the server and modifying the network settings of the interface you are
connected to, reboot the system.
. Restarting the network interface.
ifdown enp0s3
ifup enp0s3
Validate Your Network Settings
You will want to ensure that your network interface has applied your new settings. You can use the
IP command to output its settings.
ip a show enps3s0
The output will display basic information about the interface, such as device name, IP address,
MAC address, etc. The following is an example of the output.
https://www.serverlab.ca/tutorials/linux/administration-linux/how-to-configure-centos-7-network-settings/ 2/2