How to configure network interfaces in CentOS

In CentOS, Fedora or RHEL, you can configure network interfaces by using configuration files located in /etc/sysconfig/network-scripts/. For each network interface (e.g., eth0), there should be a corresponding configuration file (e.g., ifcfg-eth0) in the directory. If you would like to configure a network interface, do the following.

$ sudo vi /etc/sysconfig/network-scripts/ifcfg-eth0

If you would like to assign a static IP address to the interface:


If the interface has IP address assigned by DHCP:


Once network configuration has been created/updated, you can activate a network interface by running:

$ sudo service network restart

Note that if you are using Desktop version of Linux, you will need to disable NetworkManager first, before attempting to configure interfaces as described above.

Subscribe to Xmodulo

Do you want to receive Linux FAQs, detailed tutorials and tips published at Xmodulo? Enter your email address below, and we will deliver our Linux posts straight to your email box, for free. Delivery powered by Google Feedburner.

Support Xmodulo

Did you find this tutorial helpful? Then please be generous and support Xmodulo!

The following two tabs change content below.
Dan Nanni is the founder and also a regular contributor of He is a Linux/FOSS enthusiast who loves to get his hands dirty with his Linux box. He likes to procrastinate when he is supposed to be busy and productive. When he is otherwise free, he likes to watch movies and shop for the coolest gadgets.

Leave a comment

Your email address will not be published. Required fields are marked *