Configuring Network on CentOS/RHEL -- Basic Configuration

Interface configuration files control the software interfaces for individual network devices.

As the system boots, it uses these files to determine what interfaces to bring up and how to configure them.

These files are usually named ifcfg-<name>, where <name> refers to the name of the device that the configuration file controls.

Because each device has its own configuration file, an administrator can control how each interface functions individually.

Configure Network Interface Settings

You can configure network interface by editing configuration files stored in /etc/sysconfig/network-scripts/ directory.

Lets configure the first network interface eth0. Edit the interface configuration file.

# vi /etc/sysconfig/network-scripts/ifcfg-eth0

Append/Modify as follows :

For a system using a Static IP Address

For a system using a DHCP

Parameter Description
DEVICE=<name> Name of the physical device
BOOTPROTO=<none|bootp|dhco> Protocol to use.
none - No boot-time protocol should be used
bootp - The BOOTP protocol should be used
dhcp - The DHCP protocol should be used
ONBOOT=<yes|no> Should the device be activated at boot-time
IPADDR=<address> IP address
GATEWAY=<address> Gateway IP address
NETMASK=<mask> Netmask value

Configure Networking

Edit the main network configuration file :

# vi /etc/sysconfig/network

Append the following settings :


Restart networking :
# /etc/init.d/network restart

If the modifying of the file /etc/sysconfig/network is not needed, then you can restart only the interface :
# ifdown eth0 && ifup eth0

Configure DNS settings

Edit 'resolv.conf' file :
# vi /etc/resolv.conf

Append your DNS servers :


If you don't have private DNS servers, you can pick them from a list of Free Fast Public DNS Servers

Test Your Settings

Check if the Gateway is reachable :
# ping
Check if the Public IPs are reachable :
# ping
Check if DNS works :
# nslookup