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.
Here is my current IP configuration:
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.
Here is my current IP configuration:
[root@mylinz ~]# ifconfig -a
eth0 Link encap:Ethernet HWaddr 00:0C:29:27:0E:8A
inet addr:192.168.10.14 Bcast:192.168.10.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe27:e8a/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:3846 errors:0 dropped:0 overruns:0 frame:0
TX packets:33 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:247959 (242.1 KiB) TX bytes:4513 (4.4 KiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:18 errors:0 dropped:0 overruns:0 frame:0
TX packets:18 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1064 (1.0 KiB) TX bytes:1064 (1.0 KiB)
[root@mylinz ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
NM_CONTROLLED="yes"
ONBOOT="yes"
HWADDR=00:0C:29:27:0E:8A
TYPE=Ethernet
BOOTPROTO=static
IPADDR=192.168.10.14
PREFIX=24
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth0"
UUID=5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03
Step:1
Edit /etc/sysconfig/network-scripts/ifcfg-eth0 file as below in order to enable dhcp client.
[root@mylinz ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
NM_CONTROLLED="yes"
ONBOOT="yes"
HWADDR=00:0C:29:27:0E:8A
TYPE=Ethernet
BOOTPROTO=dhcp
PREFIX=24
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth0"
UUID=5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03
[root@mylinz ~]#
Step:2
Restart the network service to take configuration effect.
[root@mylinz ~]# service network restart
Shutting down interface eth0: [ OK ]
Shutting down loopback interface: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface eth0:
Determining IP information for eth0...^[[A done.
[ OK ]
[root@mylinz ~]# ifconfig -a
eth0 Link encap:Ethernet HWaddr 00:0C:29:27:0E:8A
inet addr:192.168.56.131 Bcast:192.168.56.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe27:e8a/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:4230 errors:0 dropped:0 overruns:0 frame:0
TX packets:61 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:273959 (267.5 KiB) TX bytes:9140 (8.9 KiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:26 errors:0 dropped:0 overruns:0 frame:0
TX packets:26 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1544 (1.5 KiB) TX bytes:1544 (1.5 KiB)
Now you can see ,server has been came up with new DHCP ip address which was automatically assigned by DHCP server.
To make the DHCP IP address as persistence, you need to add the below line in file /etc/sysconfig/network-scripts/ifcfg-eth0.
To make the DHCP IP address as persistence, you need to add the below line in file /etc/sysconfig/network-scripts/ifcfg-eth0.
PERSISTENT_DHCLIENT=1
To re-new the IP address,
# dhclient -r
# dhclient
Thank you for reading the this article.Please leave a comment ,if you have any problem.I will get back to you.
Leave a Reply