Overview
DHCP (Dynamichost configurationprotocol, Dynamic Host Configuration Protocol) is commonly used in large-scale local network environment, the main role is to centralize management, assign IP address, so that the host in the network environment to obtain the dynamic IP address, gateway address , DNS server address and other information, and can increase the usage of the address.
Working principle
1, the client boot without IP, LAN needs to send a broadcast form of Discover (LAN do not know who is the DHCP server), as long as the DHCP can receive the response
2, if the DHCP server found that there are more than one server at this time, each DHCP server will send an offer (assigning IP address, but only IP), the client receives the IP, the ARP protocol will be authenticated, whether it is occupied by other hosts, The client typically chooses the first DHCP server to give an offer.
3. At this time, the DHCP server sends a REQUESRT broadcast packet for a DHCP server (sending Request,① determines that the server is already selected ② not only sent to the DHCP server of its choice, but also to a DHCP server other than this server. Declares that the DHCP server is already selected. )
4, DHCP through the ACK mechanism will formally assign IP, gateway, subnet mask and other information are assigned to the client
About the renewal of rent:
DHCP server can be turned on 24 hours to provide services, at this time there is a problem, the client during shutdown, can again use the previous IP?
① The original used IP is not occupied, in response to an ACK, but not permanent use, IP address lease period reached 50%, must renew the lease period
② the original use of the IP has been occupied, in response to a nack, when the client resend the broadcast, according to the above four protocols re-walk again
Summary :Discover and offer are broadcast, four stages are all broadcast.
How DHCP is distributed
1. Automatic assignment: Permanent use after assigning to an IP address
2. Manual assignment: The IP address is specifically specified by the DHCP server administrator
3. Dynamic allocation: Release the IP after use for use by other clients
Advantages of DHCP
1, reduce the workload of the Administrator
2. Avoid IP address conflicts
3. When the current network changes the IP address segment, you do not need to reconfigure each user's IP address
4, improve the utilization of IP address
5, convenient configuration of the client
DHCP-assigned address information mainly includes
IP address, subnet mask of the network card
The corresponding network address, broadcast address
Default gateway Address
DNS server address
Experimental environment
System Environment: centos6.5
Host IP Address: 192.168.1.20
Yum Mount directory:/mnt/sr0
RPM Package used: dhcp-4.1.1-38.p1.el6.centos.x_86_64.rpm
Build steps
One, set DHCP address pool assignment IP
1. Server-side installation of DHCP service RPM package
[Email protected] ~]# cd/mnt/sr0/packages/
[Email protected] packages]# RPM-IVH dhcp-4.1.1-38.p1.el6.centos.x86_64.rpm
2. View the main configuration file
[Email protected] dhcp]# vim dhcpd.conf #查看主配置文件
3, optimize the configuration file and edit
[Email protected] ~]# cp/usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample/etc/dhcp/dhcpd.conf #重新覆盖配置文件
[Email protected] ~]# vim/etc/dhcp/dhcpd.conf #修改主配置文件
4. Client Testing
[Email protected] ~]# Vim/etc/sysconfig/network-scripts/ifcfg-eth0 #修改eth0网卡信息
Assigning IP to a designated host
1, check the client side of the network card MAC address
2. Open the server-side DHCP master configuration file
[Email protected] ~]# vim/etc/dhcp/dhcpd.conf
Hyper-detailed Linux configuration DHCP server