DHCP: (Dynamic Host Configuration Protocol) c/S architecture
Principle:
When the DHCP client starts, it automatically communicates with the DHCP server, which provides the DHCP client with a service that automatically assigns IP addresses. Of course, high-level DHCP, not just the distribution of the address is so simple, today our course is just to set up a normal DHCP server, the client can get access to the Internet must network configuration information. A server with DHCP service software installed is called a DHCP server, and the DHCP-enabled client is called a DHCP client, and the DHCP server serves DHCP clients in the form of address leases, which are available in the following two ways: limited tenancy and permanent lease. To learn the DHCP server, you must know how the DHCP server works
Agreement:
1. Dynamic Host Configuration Protocol
2, LAN, UDP protocol
Main uses:
1, the user's internal network service provider automatically assigns the IP address to the user
2, the user internal manager as a means of central management of all computers
Usage scenarios:
1. Solve the problem of insufficient resources of IPV4
2. Automatic Installation System
Work Flow:
1, in the LAN host are access through the MAC address, the client before the IP, broadcast way 255.255.255.255 to the internal host, who has IP resources
2, when the DHCP service in our local area network, DHCP will respond to it, by unicast to tell it I have IP resources here
3, the customer requests an IP resource to the DHCP service
4. DHCP confirms and provides an IP resource
Attention:
1, if a network segment has multiple DHCP services, then who receives the request first, who responds first, the other DHCP service only need to reply to the first broadcast packet to
2, different network segments can also provide DHCP services, we need to Dhcprelay relay services to provide IP allocation for different network segments, in addition, DHCP wants to serve different network segments, must first provide services for their own network segment;
3, IP lease time, each IP distributed to the host, there will be a use of the length of time, once the length of time need to continue to use then you need to renew, when the lease length reaches 50%, the customer will ask the DHCP service to renew the lease, if the DHCP service so continue leases, if not respond, when reached 75 %, the DHCP service will be contacted again, if not the response at 87.5% will be a renewal of the lease, if not successful then the customer will think that the DHCP service does not exist or contact;
Configuration file
/ETC/DHCP # #dhcp服务家目录
/etc/dhcp/dhcpd.conf # #dhcp服务配置文件
/etc/dhcp/dhcpd6.conf # #dhcp的ipv6服务配置文件
/etc/openldap/schema/dhcp.schema # #dhcp服务配置文件模板
/usr/bin/omshell # #在不重启DHCP服务的情况下实现配置加载
Example: Configuring a DHCP server to provide IP resources for internal and external hosts (note: The DHCP server itself must be a static IP)
1. Install DHCP service
[[email protected] ~]# Yum install-y DHCP
2. Generate Configuration file
[Email protected] ~]# cp/usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample/etc/dhcp/dhcpd.conf
3, Profile Introduction (note that the configuration in the global configuration can also be configured in the outside subnet)
Option Domain-name "example.org"; # #默认的搜索域
option Domain-name-servers; # #DNS服务器, a maximum of three are separated
Default-lease-time 600; # #最短的租赁时长
Max-lease-time 7200; # #最大租赁时长
Log-facility Local7; # #日志级别
option routers; # #默认路由表
Subnet 10.152.187.0 netmask 255.255.255.0 {# #DHCP提供的IP资源池的配置
}
4, simple configuration DHCP server, provide IP resources, and search domain and DNS
650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M01/8C/45/wKioL1hn6_PA9B5MAAATaouOHSY284.png-wh_500x0-wm_3 -wmp_4-s_2199033191.png "style=" Float:none; "title=" 1.png "alt=" Wkiol1hn6_pa9b5maaataouohsy284.png-wh_50 "/>
650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M00/8C/48/wKiom1hn6_Oh4t6AAAAUiPVotic805.png-wh_500x0-wm_3 -wmp_4-s_651527.png "style=" Float:none; "title=" 2.png "alt=" Wkiom1hn6_oh4t6aaaauipvotic805.png-wh_50 "/>
5. Restart the test
650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M00/8C/45/wKioL1hn7AWx8xvaAABLzFYDplc748.png-wh_500x0-wm_3 -wmp_4-s_386320644.png "title=" 3.png "alt=" Wkiol1hn7awx8xvaaablzfydplc748.png-wh_50 "/>
View the owning domain and DNS
650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M01/8C/48/wKiom1hn7BuS0E-9AAARVfnWTr0158.png-wh_500x0-wm_3 -wmp_4-s_2188217633.png "title=" 4.png "alt=" Wkiom1hn7bus0e-9aaarvfnwtr0158.png-wh_50 "/>
6. Configure the specified route
650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M02/8C/48/wKiom1hn7DujBMtzAAANQSWMRlo506.png-wh_500x0-wm_3 -wmp_4-s_3832278328.png "title=" 5.png "alt=" Wkiom1hn7dujbmtzaaanqswmrlo506.png-wh_50 "/>
7. Restart the test
650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M01/8C/45/wKioL1hn7EOzmNrtAAArve6r_nI451.png-wh_500x0-wm_3 -wmp_4-s_2803890271.png "title=" 6.png "alt=" Wkiol1hn7eozmnrtaaarve6r_ni451.png-wh_50 "/>
8. Bind MAC Address
650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M02/8C/48/wKiom1hn7GHTnGysAAAgJVqka2M250.png-wh_500x0-wm_3 -wmp_4-s_2075031190.png "title=" 11.png "alt=" Wkiom1hn7ghtngysaaagjvqka2m250.png-wh_50 "/>
9. Restart the test
650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M02/8C/45/wKioL1hn7GjAx0dHAABNgNFXeL4097.png-wh_500x0-wm_3 -wmp_4-s_433390341.png "title=" 22.png "alt=" Wkiol1hn7gjax0dhaabngnfxel4097.png-wh_50 "/>
A Concise DHCP service configuration
[Email protected] ~]# cat/etc/dhcp/dhcpd.conf
Option Domain-name "www.cce.com";
Option Domain-name-servers 192.168.1.62;
Default-lease-time 600;
Max-lease-time 7200;
Log-facility Local7;
Subnet 192.168.1.0 netmask 255.255.255.0 {
Range 192.168.1.110 192.168.1.120;
Option routers 1.1.1.1;
}
Host Guding {
Hardware Ethernet 00:0C:29:1C:55:CC;
Fixed-address 192.168.1.254;
}
This article from "Char" blog, declined reprint!
DHCP Fundamentals and configuration of automated installation