* Mind Mapping
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/73/1B/wKiom1X1JSaiZEI9AAdkjP6gDGI938.jpg "title=" screen shot 2015-09-13 pm 3.06.06.png "alt=" Wkiom1x1jsaizei9aadkjp6gdgi938.jpg "/>
I. Overview
1. DHCP: Automatic host Configuration Protocol
The port number is:
IPv4 corresponds to UDP67, 68
IPv6 corresponds to udp546, 547
2, the role: to achieve automatic allocation to the host IP, default gateway, DNS and other address information
3. Benefits:
Reduce the workload of administrators
Avoid input errors
Avoid IP collisions
Convenient Client Configuration
Increase IP Address utilization
4. Distribution method:
Auto Assign: Assign to an IP address for permanent use
Manual assignment: IP address specifically assigned by DHCP administrator
Dynamic allocation: Frees the IP for use by other clients when finished
5. Why use the server to build DHCP
specificity, high stability
Second, the DHCP lease process (like renting)
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/73/19/wKioL1X1Ku_TEY3_AAFQcQSzkeY573.jpg "title=" Showimage-10038307-10000159-4250ee41945e958cf237b60924ced946.jpg "alt=" Wkiol1x1ku_tey3_aafqcqszkey573.jpg "/>
1. Lease Process:
1) The client sends a DHCP Discover broadcast packet, looking for a DHCP server
The client source IP is 0.0.0.0, and the source Mac is its own native Mac.
2) The server responds to the DHCP offer package
Provide available IP, lease information, etc.
3) client sends DHCP request
Declare the DHCP server of your choice
Send ARP broadcast to confirm that the IP address is not occupied
4) The server sends ACK acknowledgement
This ACK packet contains all the network parameters assigned to the client.
2. After the client restarts:
1) Send DHCP Request packet with IP address
2) If the IP address is not allocated for use, the DHCP server responds to ACK acknowledgement and the client continues to use the IP
3) If the IP address is occupied by someone else, the DHCP server responds to the NACK packet, informing the client that the IP is occupied. The client then re-sends the Discover broadcast packet
3, update the lease:
1) The lease period must be renewed after the IP address lease reaches 50%
2) The client sends the DHCP request package directly to the server to update the lease period
Third, DHCP server configuration
1. Related Documents
Service Name:dhcpd, Dhcrelay(relay service)
Master configuration file:/etc/dhcp/dhcpd.conf
Template files:/usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample
Trunk profile:/etc/sysconfig/dhcrelay
2, the main configuration file related parameter explanation
# Global configuration:
Option Domain-name # Setting the DNS domain
Option DOMAIN-NAME Servers # set DNS server IP address
Default-lease-time # Default Lease time
Max-lease-time # Maximum Lease time
# Subnet Options:
Subnet 172.16.1.0 netmask 255.255.255.0 {
Range 172.16.1.100 172.16.1.200;
Option Domain-name-servers 114.114.114.114,223.5.5.5;
Option routers 172.16.1.1;
Default-lease-time 600;
Max-lease-time 7200;
}
#subnet represents the network segment currently being assigned by DHCP. Note that the DHCP server must be located in this network segment
#range represents the assigned address range
#option domain-name-servers represents the assigned DNS address
#option routers represents the assigned gateway address
# Reserved Address option:
# Sometimes we need to configure a fixed IP address for a host, and the host option option satisfies this requirement.
Host Server2 {
Hardware Ethernet 08:00:07:26:C0:A5;
Fixed-address 172.16.1.166;
}
#hardware Ethernet MAC for the specified host
#fixed-address the specific IP address to which the host is assigned
3. DHCP server configuration process
1) Copy template files
Because there is no content in the default Master profile/etc/dhcp/dhcpd.conf (except for comments), it is not easy to configure. So you need to copy the template file and rename it to overwrite the master profile.
2) Modify the master configuration file
Add subnet, delete the useless subnet in the template
If there is a reserved address, add the relevant configuration in the host option
3) Turn on DHCP service
Service DHCPD Start # Start the DHCP service
Netstat-anpu | grep dhcp #查看dhcp状态
Note: If an error starts failing, check the/var/log/messages log, read the wrong reason, and make a mistake.
4) View lease information
Server-side lease file:/var/lib/dhcpd/dhcpd.leases
Client lease file:/var/lib/dhclient/dhclient-eth0.leases
4. DHCP Relay configuration process
1) Add the subnet that need to be relayed in the master profile /etc/dhcp/dhcpd.conf on the DHCP server and restart the DHCP service
2) Turn on packet forwarding on the relay server
[Email protected] ~]# vim/etc/sysctl.conf
Net.ipv4.ip_forward = 1
[Email protected] ~]# sysctl-p
# Update configuration file
3) Add parameters to the configuration file/etc/sysconfig/dhcrelay on the relay server
[Email protected] ~]# Vim/etc/sysconfig/dhcrelay
interfaces= "Eth0 ehth1" #声明你要使用哪几块网卡中继
Dhcpservers= "172.16.1.201" # Specify DHCP server
4) Start the relay service on the relay server
Service Dhcrelay Start
This article is from "Brother Hua on the Road" blog, please be sure to keep this source http://wshstc.blog.51cto.com/10676059/1694283
Build DHCP services under Linux