Boy, you know want to practice TCP / IP holy canon, we must first ...... (DHCP protocol detailed)

In order to use the TCP / IP protocol suite, each host and router needs some configuration information. Configuration information is used to specify the name of the local system, and to specify an identifier (e.g. IP address) is connected day. Over the years, many methods have been available, and access to such information, but basically three methods: manual access to information, access to network services through the use of a system, using an algorithm, or determined automatically.

1 DHCP is exactly what the hell?

DHCP (Dynamic Host Configuration Protocol) Dynamic Host Configuration Protocol, is a popular client / server protocol, which is used as a host (sometimes as a router) to specify configuration information. An early design is based on DHCP protocol called Intemet a Bootstrap Protocol (BOOTP), which is obsolete .. BOOTP providing customers with limited configuration information, and does not provide a mechanism to support the change information already provided.
Here Insert Picture Description

2 address pool, and lease

In dynamic allocation, DHCP client requesting allocation of an IP address. Select a server address as a response from the pool of available addresses. Under normal circumstances, this pool is a contiguous range of IP addresses specifically allocated for the purpose of DHCP address assigned to the client is valid only for a specified period of time, this period is called the rental period, the rental period may range from a few minutes to several days or longer.

2.1 determine the lease time

To determine the optimum value of the rental period need to be weighed against factors expected number of customers, the size of the address pool and address stability. Longer lease generally available pool of addresses run out quickly, but it provides a more stable address and reduce network overhead (as renewal requests less). Shorter lease may provide higher availability address pool for other clients, followed by stability and reduce network traffic load increases. Common default values 12--24 hours depending on the DHCP server. Microsoft recommends smaller networks in 8 days, larger networks using 16--24 days. When the client lease more than half began to try to renew the lease.

When the server provides leases to the client, the server will lease information stored in persistent storage, usually a non-volatile memory or disk. If the DHCP server is restarted and running well, the lease will remain intact.

3 DHCP message format and BOOTP

DHCP packet interaction in different scenarios. But the essence of the DHCP packet lies DHCP Option, we know DHCP packets main role is assigned to the client server IP.

DHCP extends BOOTP (which is the predecessor of DHCP). DHCP message format defined by way of extension of BOOTP, to maintain compatibility between the two protocols, so that even if the network is not installed in the DHCP server, the client can still use BOOTP DHCP server and BOOTP relay agent (see 6.2. section 6) support DHCP services.
Message format includes an initial portion of the tail of fixed length and a variable length.
Here Insert Picture Description

  1. OP (operation) field identifies the message is a request (1) or response (2).
  2. HW allocation type (htype) based on the value of field use ARP, and parameters defined in the corresponding page of IANAARP [IARP], the most common value is 1 (Ethernet).
  3. HW length (hlen) field is used to store hardware (MAC) address for Ethernet-like networks, the value is usually 6.
  4. Jump field holds the number of hops the message during transmission. Message sender is set to the value 0, and is incremented each time the relay. With survival IP datagram almost.
  5. Transaction ID is a (random) number chosen by the client, the server needs to copy it to the response. It is used to match the response with the request.
  6. The number of seconds (Secs) field is set by the client, it is the first attempt to apply or re-apply for the number of seconds elapsed address.
  7. The current flag field contains only a bit after a defined, known as the broadcast flag. The client may request this bit is set, indicating that they can not or do not want to handle unicast IP datagram, the datagram may be processed broadcast (e.g., because they do not have an IP address).
  8. Client IP address (ciaddr) field includes the IP address of the requester (if known), and 0 otherwise.
  9. "Your" IP Address (yiaddr) field is filled in by the server to provide the address of the server to the requestor.
  10. The next server IP address (the siaddr) field gives the address of the next server, which is used to boot the client process (e.g., if the client may need to download a server needs to be done other than by another DHCP server operating system mirroring).
  11. 'Gateway (relay) IP address (the giaddr) field is filled in by the DHCP or BOOTP relay their own return address when forwarding DHCP (BOOTP) message.
  12. Client hardware address (the chaddr) field holds a unique identifier for the client, and may be used in different ways by the server, including the same assigned IP address each time when a client sends an address request. This field is typically stored MAC address of the client, which is used as an identifier. At present, the client identifier (Section 6.2.3 and options described in Section 6.2.4) is its first choice.
  13. Server name (sname) and boot file name (file) field. These fields are not always required to complete, which comprise 64 bytes or 128 bytes ASCⅡ characters, indicates that the server name or start the file path.
  14. The last field in the BOOTP was originally called the vendor extensions field, its length is fixed, now called the options field, but the length of the variable.

4 DHCP and BOOTP Options

Information distribution server to the client can have many, many, such as a server via DHCP packets to tell who is a client gateway, subnet mask, how much, who is the DNS server, NTP server is who and so on. And this information is to tell the client via DHCP Option.
Here Insert Picture Description
Here Insert Picture Description

5 DHCP protocol operations

BOOTP DHCP message is a message with a special set of options. When a new client connects to the network, it first found DHCP server is available, and they can provide an address. It then decide which server and which address to use, and provide the server sends a request to the address (select the notification while it all servers). Unless the server has been allocated out of the address during this time, otherwise it will be assigned to the requesting client by confirming address.

BTree two trees: the DHCP protocol family operation
URL: https: //www.bilibili.com/video/BV1Xg4y1b78J
Here Insert Picture Description

6 DHCP state machine

DHCP protocol state machine running a client and a server. Status message type for indicating a next protocol processing. Figures 6-10 describe the client state machine. Transitions between states (arrow) from the receiving and sending messages or timeout.
Here Insert Picture Description

7 DHCPv4

DHCPv4 in the TCP / IP protocol detailed: Volume Agreement (Second Edition) there is no, there are no very specific description, CSDN there about Bowen is relatively small, probably because DHCPv4 is actually relatively old, useless.

Then, I: peas agent (which is a proxy doing IP site) of " cases, said graphic TCP / IP protocol suite -DDI articles (2) DHCPv4 protocol Advanced " at: https: //www.wandouip.com / t5i284825 /

Find some content presentation, but the blogger does not know the contents of the DHCPv4 (I find the TCP / IP protocol detailed: Volume Agreement (Second Edition) there is no).
And then compare DHCPv6 can see this blog: CSDN bloggers kdb_viewer of " DHCPV6 VS DHCPv4 ", URL: https: //blog.csdn.net/kdb_viewer/article/details/83310904

Not to paste the copied, original articles of slag male others should do.

8 DHCPv6

DHCP packet interaction in different scenarios. But the essence of the DHCP packet lies DHCP Option, we know DHCP packets main role is assigned to the client server IP. In stateless mode, IPv6 clients believe their own can configure IPv6 addresses, but require additional information (such as DNS server addresses) via DHCPv6.

8.1 IPv6 lifecycle

Each interface typically has a plurality of IPv6 host addresses, and each address has a set of timers, can be used to indicate how long the corresponding address and for what purpose. In IPv6, address assignment includes a preferred lifetime and valid lifetime. The life cycle for determining time out, the own address in the state machine from one state to another state.

Lifecycle IPv6 addresses. Temporary address is for DAD, until it is verified as unique. Since then, they become the preferred address, and unlimited use until the timeout to change its status as obsolete. Waste can not be used to initialize a new connection address, and may not be effectively used after the timeout expires.
Here Insert Picture Description

8.2 DHCPv6 message format (the most meaningful information carried in the options)

DHCPv6 message is encapsulated UDP / IPv6 datagram, it uses the client-side and server-side Day 546 Day 547. Message to the relay agent or server, it uses the source address of link-scope of a host. Here there two message formats, for a between client and server, for another relay agent.
Here Insert Picture Description
Left in the message format includes a message type typical DHCP message (REQUEST, REPLY, etc.), right in the message format includes a message type and RELAYLFORW RELAYLREPL, respectively, from the relay agent and forward the message destination is a relay agent . Right option field comprises a relay message option, which contains the complete message is relayed. Other options may also be included.
Here Insert Picture Description
In DHCPv6, the most meaningful information carried in options, including address, lease time, location services, and client identifier and server identifier. These options are two important concepts associated with the use of identity (IA) and DHCP unique identifier (DUID). We will be discussed later.

8.3 identity association

Identity association (IA) is an identifier used between the DHCP client and a server, for a set of addresses pointing to. Each includes an IA IA identifier (the IAID) and related configuration information. Each request is assigned an address DHCPv6 client access needs at least one day each IAo IA may be associated with only one by day. IA ID unique address of the client's choice to identify each IA, this value will be shared with the server.

当服务器响应一个请求时,它为客户机的IA分配一个或多个地址,分配时基于服务器管理员确定的一组地址分配策略。在通常情况下,这些策略依赖于请求所到达的链路、客户机的标准信息(DUID),以及DHCP选项中由客户机提供的其他信息。

Here Insert Picture Description

8.4 DHCP唯一标识符(DUID)

DHCP唯一标识符(DUID)用于标识一台DHCPv6客户机或服务器,并被设计为可持续一段时间。服务器用它标识所选地址(作为IA的一部分)对应的客户机和配置信息,客户机用它标识感兴趣的服务器o DUID长度是可变的,对于大多数用途来说,客户机和服务器将它看作一个不透明的值。

DUID有三种类型:

  1. DUID—LIT :基于链路层地址和时间的DUID,它是推荐的格式。在硬件类型之后,它包括一个32位的时间,其中的秒数开始于2000年1月1目午夜(UTC)(mod232)。它将在2016年归零(返回0)。最后部分是一个可变长度的链路层地址。 链路层地址可由任何主机接口选择,并使用相同的DUID,一旦选定,它可用于与任何接口的通信。这种格式的DUID是稳定的,使网络接口从该DUID中移除。因此,它需要主机系统固定存储相关信息。
  2. DUID-EN : 基于企业编号和供应商分配的DUID。
  3. DUID类型 :但也不是只能创建这三种类型。

一个标准格式的DUID编码开始于一个2字节的标识符,用于指出哪种类型的DUID。当前列表由IANA维护。。在DUID-LIT和DUID-LL中,紧跟着是一个来自[RFCO826]的16位的硬件类型;在DUID-EN中,则是一个32位的专用企业编号。

8.5 DHCPv6协议操作(注意于上面有区别)

Here Insert Picture Description

9 使用DHCP中继

Here Insert Picture Description

在最简单的网络中,一个DHCP服务器可供同一局域网中的客户机使用。但是,在更复杂的网络中,可通过一个或更多DHCP中继代理来中继DHCP流量,以此来将DHCP操作扩展到跨越多个网段。

在一般情况下,中继不会参与客户机和服务器之间的所有DHCP流量交换。相反,它仅中继那些广播消息(或IPv6中的组播)。这种消息通常在客户机首次获得自已的地址时交换。

10 参考资料:

CSDN博主DHCP协议 详解的《DHCP协议 详解》,网址:https://blog.csdn.net/windeal3203/article/details/50677166?depth_1-utm_source=distribute.pc_relevant.none-task&utm_source=distribute.pc_relevant.none-task

CSDN博主pythonchuxue的《DHCP原理及配置》,网址:https://blog.csdn.net/qq_41636653/article/details/81751060?depth_1-utm_source=distribute.pc_relevant.none-task&utm_source=distribute.pc_relevant.none-task

CSDN博主kdb_viewer的《DHCPV6 vs DHCPV4》,网址:https://blog.csdn.net/kdb_viewer/article/details/83310904

豌豆代理(这是一个做IP代理的网站)的《例说图解TCP/IP协议族–DDI篇(2)DHCPv4协议进阶》,网址:https://www.wandouip.com/t5i284825/

TCP/IP协议详解(原书第二版)卷1:协议 P160-208

Released eight original articles · won praise 22 · views 1783

Guess you like

Origin blog.csdn.net/qq_45877524/article/details/105113751