≡ Menu

Setting Up a CentOS / Red Hat Linux DHCP Client

Q. How do I setup my Red Hat / CentOS / Fedora Linux system to get IP address and other information via a DHCP server for eth0 interface?

A. You can edit eth0 configuration file to switch between static and dhcp networking configuration under RHEL / Fedora or CentOS Linux. Simply edit /etc/sysconfig/network-scripts/ifcfg-eth0 file.

Backup existing static configuration

First backup existing network configuration file using cp command:
# cp /etc/sysconfig/network-scripts/ifcfg-eth0 /root/ifcfg-eth0.bak

Configuring a DHCP Client

Setting up a Linux for dhcp can be done by editing file using a text editor such as vi:
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
Following is sample static configuration:

Replace static configuration with DHCP:

Save and close the file. Just restart network service:
# /etc/init.d/network restart
Please note that you need a configuration file for each device that you want to configure to use DHCP.

Share this tutorial on:

Your support makes a big difference:
I have a small favor to ask. More people are reading the nixCraft. Many of you block advertising which is your right, and advertising revenues are not sufficient to cover my operating costs. So you can see why I need to ask for your help. The nixCraft, takes a lot of my time and hard work to produce. If you use nixCraft, who likes it, helps me with donations:
Become a Supporter →    Make a contribution via Paypal/Bitcoin →   

Don't Miss Any Linux and Unix Tips

Get nixCraft in your inbox. It's free:

{ 6 comments… add one }
  • Ria July 13, 2009, 12:35 pm

    This info was of great help!

  • PM September 15, 2010, 3:26 pm

    Actually on F13 minimal you have to create the mentioned file! but still works very great :)

  • Nathan November 4, 2010, 4:16 pm

    Is there any post around about configuring dhcp server on CentOS/Redhat?!!

  • Hemant Parmar December 8, 2011, 12:14 pm

    in my system have same problem but when i am restarting my computing again eth0.bak is coming..please help me. i done everything but it is not working.

  • Arnau February 1, 2012, 9:20 am

    It works like a charm! Thanks a lot

  • Noordeen January 13, 2015, 6:46 am

    @Hemant Parmar: Change the ONBOOT: No in eth0.bak

Leave a Comment

You can use these HTML tags and attributes: <strong> <em> <pre> <code> <a href="" title="">

   Tagged with: , , , , , , , , , , , , , , , , , , , , , ,