DHCP principle and its implementation process

First, what is DHCP?

  DHCP, Dynamic Host Configuration Protocol, formerly known as BOOTP protocol, is a local area network protocol, uses UDP protocols work, commonly used two ports: 67 (DHCP server), 68 (DHCP client). DHCP is commonly used in LAN environments, the main role is to focus on the management, assign an IP address, the client information dynamically obtain an IP address, Gateway address, DNS server address, etc., and can enhance the utilization of addresses. In simple terms, DHCP is an unwanted account password, the protocol automatically assigns IP addresses and other information to the machine within the network.

 

  Two, DHCP functionality

  1, to ensure that any IP address can only be used by a DHCP client at the same time.

  2, DHCP can be permanently assigned a fixed IP address to the user.

  3, DHCP may be obtained with other methods coexist host IP address (e.g., manually configure the host IP address)

  4, DHCP server should provide service to existing BOOTP clients.

  Three, DHCP principle

  dhcp principle and its implementation process

  IP address of the DHCP request is as follows:

  1) The master sends a broadcast DHCPDISCOVER packet finds a DHCP server on the network;

  2) DHCP server sends a unicast to the host DHCPOFFER packet that contains an IP address, MAC address, the domain name information and address lease;

  3) The master sends a broadcast DHCPREQUEST packet, requests a formal IP address assignment provided to a server;

  4) DHCP server sends DHCPACK unicast packet to the host, the host confirmation request

  Note that: the DHCP client may receive multiple DHCP servers DHCPOFFER packet, and may accept any one DHCPOFFER packet, the client usually accept the first received DHCPOFFER packet. Further, the DHCP server specifies the DHCPOFFER [1] is not necessarily the address of a final address assignment, usually, the DHCP server retains this address until the client sends a formal request.

  Formal request DHCP server address using the DHCPREQUEST broadcast packet, the DHCP server to all other DHCPOFFER packet transmission is also capable of receiving the data packet, and then by releasing the OFFERs (pre-assigned) IP addresses to the client.

  If the end of the address of the DHCP client has been sent to the other DHCP client, the client sends a packet DHCPDECLINE refused to accept address information has been assigned to the server.

  In the negotiation process, if the address information of the DHCP REQUEST message sent by the client are not correct, if the client has migrated to the new subnet or lease has expired, DHCPNAK DHCP server sends a message to the DHCP client, allowing the client to re address request to initiate the process.

  Four, DHCP advantages and disadvantages

  DHCP service many advantages: The network administrator can verify the IP address and other configuration parameters, without having to check each host; DHCP lease will not give the same IP address simultaneously two hosts; DHCP bound to a particular computer administrator can use a particular IP address; you can set many options for each DHCP scope; clients do not need to re-set the IP address when you move between different subnets.

  But there are also many shortcomings: DHCP IP address on the network can not find non-DHCP clients already in use; when there are multiple DHCP servers on the network, a DHCP server can not detect that has been rented out to other server IP addresses; DHCP server across a router can not communicate with the client, unless the router allows BOOTP forwarding.

  dhcp principle and its implementation process

  Five, dhcp implementation process

  1, the discovery phase, where the DHCP client locate a DHCP server. DHCP client in broadcast mode (because the IP address of the DHCP server to the client is unknown) sends DHCP discover discovery information to find a DHCP server, namely broadcast address 255.255.255.255 send specific information. Each installed on the network TCP / IP protocol host will receive this broadcast information, but only a DHCP server will respond.

  dhcp principle and its implementation process

  2, to provide phase, the DHCP server offers an IP address. In the network received DHCP discover discovery DHCP server will respond to information, which is assigned to the selection of a DHCP client from the IP address has not been rented, the sending DHCP offer a lease contains the IP address and other settings to DHCP clients provide information.

  dhcp principle and its implementation process

  3、选择阶段,即DHCP客户机选择某台DHCP服务器提供的IP地址的阶段。如果有多台DHCP服务器向DHCP客户机发来的DHCP offer提供信息,则DHCP客户机只接受第一个收到的DHCP offer提供信息,然后它就以广播方式回答一个DHCP request请求信息,该信息中包含向它所选定的DHCP服务器请求IP地址的内容。之所以要以广播方式回答,是为了通知所有的DHCP服务器,他将选择某台DHCP服务器所提供的IP地址。

  dhcp principle and its implementation process

  4、确认阶段,即DHCP服务器确认所提供的IP地址的阶段。当DHCP服务器收到DHCP客户机回答的DHCP request请求信息之后,它便向DHCP客户机发送一个包含它所提供的IP地址和其他设置的DHCP ack确认信息,告诉DHCP客户机可以使用它所提供的IP地址。然后DHCP客户机便将其TCP/IP协议与网卡绑定,另外,除DHCP客户机选中的服务器外,其他的DHCP服务器都将收回曾提供的IP地址。

  dhcp principle and its implementation process

  5、重新登录。以后DHCP客户机每次重新登录网络时,就不需要再发送DHCP discover发现信息了,而是直接发送包含前一次所分配的IP地址的DHCP request请求信息。当DHCP服务器收到这一信息后,它会尝试让DHCP客户机继续使用原来的IP地址,并回答一个DHCP ack确认信息。如果此IP地址已无法再分配给原来的DHCP客户机使用时(比如此IP地址已分配给其它DHCP客户机使用),则DHCP服务器给DHCP客户机回答一个DHCP nack否认信息。当原来的DHCP客户机收到此DHCP nack否认信息后,它就必须重新发送DHCP discover发现信息来请求新的IP地址。

  6, lease renewal. DHCP server to the DHCP client leased IP addresses generally have a lease period, after the expiration of the IP address of the DHCP server will recover rent. If the client wants to extend its IP DHCP lease, it must renew its IP lease. And an IP lease duration than half, DHCP client will automatically send updates its IP lease to the DHCP server when the DHCP client starts.

  To facilitate understanding, we compared the DHCP Client restaurant guests, DHCP server likened waiter (a restaurant where you can have multiple attendants), IP address food likened customer needs. In this way you can describe the whole process: the guests walked into the restaurant and asked: "Is there waiter ah?" (DHCP discover), multiple simultaneous waiter replied: "Yes, I have these wings" "Yes, I have this burger" (DHCP offer). Guests say: "Well, I'll have a hamburger" (DHCP request, the guests more rigid, always choose the first time I heard the food), holding the Hamburg staff responded loudly: "Coming" (DHCP ack ), and the food ended in front of the guests, for which enjoy (the network card and IP address binding). Guests come next time, they point directly to the waiter last time your favorite burgers (DHCP request), if there is hamburger, the waiter will confirm again and serve (DHCP ack), and if already sold out, the waiter guests will be told: "sorry, sold out" (DHCP nack). Of course, the waiter will from time to time to clean up once the table, unless otherwise indicated guests would continue to eat this dish, the waiter will take away the leftovers.

Guess you like

Origin www.cnblogs.com/hll16/p/11942997.html