Features DHCP (Dynamic Host Configuration Protocol) is a LAN network protocol that uses UDP for two purposes: to automatically assign IP addresses to internal network or network service providers, it provides users or internal network administrators with central management measures for all computers. Udp67 and udp68 are normal Dhcp Service ports, which serve as DHCP server and DHCP Client respectively. The initialization process similar to DHCP allows users to automatically set their networks and connect to the Internet without knowing the addresses, routes, and masks.
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/6D/0E/wKioL1VbS6WCgUX_AACormk7deU004.jpg "/>
Understanding of the Principles (through the analysis of DHCP status)
1. First-stage search for DHCP server Broadcast
If the client wants to about the DHCP server, but we know that the client does not necessarily know the address of the DHCP server in the network, broadcast the IP address 0.0.0.0 255.255.255.255, you can establish a first contact with the DHCP server.
As described above, we know that DHCP uses UDP to send packets, which may lead to delay or damage. In this case, DHCP uses timeout and retransmission technologies to achieve a certain degree of reliability. Once a user sends a request, the timer is started, and the user must re-transmit the timer.
For the format of DHCP packets, refer
Field
OP: option, indicating the request or response
Htype: hardware type, network hardware type
Hlen: hardware address length. For example, if the Ethernet type is 1, the length is 6.
Hops: Number of hops, number of routers passing through
Transaction ID: number used to process requests and responses
Seconds: the number of seconds after the client sends the message.
Client IP Address: indicates the user's IP address. If the user knows the required DHCP server information, the user will continue according to the user's situation; otherwise, no write
Your IP Address: your IP address. When your IP address is 0, the server returns a customer IP address in this field.
Server IP Address: Server IP Address
Server Host Name: Server Host Name
Flags: allows control of requests and responses. Currently, only the highest bit is useful. When B is used, it indicates broadcast, and the other bit is 0.
2. The server responds to the second stage and provides client lease information for you to select unicast. You can locate it through Mac.
About leasing (lease)
The DHCP server first manages an IP address pool. When a user applies, the server first checks the log file to see if the user has used an IP address, otherwise, one user is automatically allocated. If the configuration file sets a fixed IP address for the MAC address, the IP address is provided. Otherwise, select an unused IP address from the pool and record it.
As for the lease term, for different occasions, such as universities, companies, and ordinary users, their lease term is generally different. In order to use IP addresses more effectively, DHCP allows users to apply for a lease term. By default, you can assign a permanent address for an unlimited (infinity) lease period.
Relay agent)
The relay proxy is used to cope with such a situation. The multi-port computers in the network are in multiple networks, while our DHCP server usually has only one, in order to achieve a breakthrough that only one IP Address can correspond to one host, the relay proxy (usually a router) temporarily acts as the proxy DHCP to receive the client broadcast application, and the proxy forwards the application to the server ,, then return the server's response to the client. DHCP identifies the value of a specific interface through the Client Identifier to distinguish different requests sent by the same customer.
3. The DHCP lease determined by the client in stage 3 is sent to the server for confirmation broadcast.
Due to the possibility of Multiple DHCP servers, users usually choose the first DHCP server to respond and tell other hosts that the lease can be withdrawn.
4. In Stage 4, the server records the customer's lease information and sends a response to inform the client that the client can use
Now the lease starts timing.