What is DHCP ?
Dynamic Host Configuration Protocol (DHCP) is server/client protocol where DHCP server provides an IP address automatically with necessary information like subnet and gateway to DHCP clients.
How to configure DHCP client on Redhat Linux /Cent OS ? What are the files need to be edited to enable DHCP client ? Here we are going to see how to setup DHCP client where your system is already running with static IP and also we are going to see about how to set persistent DHCP client.In the last part of article we will see how to re-new the IP address which is assigned by DHCP server.
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:
DEVICE=eth0 BOOTPROTO=static HWADDR=00:19:D1:2A:BA:A8 IPADDR=10.10.29.66 NETMASK=255.255.255.192 ONBOOT=yesReplace static configuration with DHCP:
DEVICE=eth0 BOOTPROTO=dhcp HWADDR=00:19:D1:2A:BA:A8 ONBOOT=yes
Save and close the file. Just restart network service:
# /etc/init.d/network restart