码迷,mamicode.com
首页 > 其他好文 > 详细

DHCP

时间:2021-05-24 14:38:40      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:each   war   connect   rgb   mit   nta   mini   out   traffic   

DHCP (Dynamic Host Configuration Protocol): An application-layer client-server protocol for allowing a device to automatically obtain an IP address.

DHCP also allows a host to learn additional information, e.g. its subnet mask; the address of its first-hop router (i.e. the default gateway); the address of its local DNS server.

A network administrator can configure DHCP so that a host 1) receives the same IP address each time it connects to the network; or 2) is assigned a temporary IP address that will be different each time it connects to the network.

DHCP is often referred to as a plug-and-play protocol.

DHCP is useful in residential Internet access network, wireless LANs and residential ISP access network.

DHCP relies on UDP as its transport layer protocol, it has its own built-in reliability measures.

DHCP Packet Structure

技术图片

OpCode: indicates whether the packet is a DHCP request or reply;

Hardware type: the type of hardware address, e.g. 10MB Ethernet, IEEE802, ATM;

hardware length: the length of the hardware address;

Hops: Used by relay agents to assist in finding a DHCP server;

Transaction ID: A random number used to pair requests with responses;

Seconds Elapsed: Seconds since the client first requested an address from the DHCP server;

Flags: The type of traffic the DHCP client can accept e.g. unicast, broadcast;

Client IP Address: The client‘s IP address (derived from Your IP Address field);

Your IP Address: The IP address offered by the DHCP server (ultimately becoms the Client IP Address field value);

Server IP Address: The DHCP server‘s IP address;

Gateway IP Address: The IP address of the network‘s default gateway;

Client Hardware Address: The client‘s MAC address;

Server Host Name: (optional) The server‘s host name 

Boot File: (optional) A boot file for use by DHCP

Options: Used to expand the structure of the DHCP packet to give it more features.

4-step process of DHCP Initialization: Discover-Offer-Request-Acknowledgment

-- this DORA process occurs the first time a client gets an IP address or when its lease has expired.

技术图片

技术图片

1) DHCP server discovery

The client passes an IP datagram that encapsulate DHCP discover message (a UDP packet to port 67), with broadcast destination IP address (255.255.255.255) and “this host” source IP address (0.0.0.0, because it does not yet have an iP address)to the link layer.

e.g. DHCP discover packet 

技术图片

requested IP Address: supplies the IP address the client would like to receive, cna be previously used IP address or 0.0.0.0 to indicate no preference.

parameter request list: lists the different configuration items (IP addresses of other important network devices and other non IP items) the client would like to receive from DHCP server. 

2) DHCP server offer(s)

A DHCP server responds with a DHCP offer message (contains the transaction ID of the received discover message, the proposed IP address for the client, other additional information: subnet mask, IP address lease time, router address, domain name ...) that is broadcast to all nodes on the subnet.

e.g. DHCP offer packet

技术图片

transaction ID: the same as the previous discover packet, indicating this is the response to the original request;

Your IP address: the IP address offered to the client;

3) DHCP request

The client choose from among one or more server offers and respond to one with a DHCP request message, echoing back the configuration parameters.

e.g. DHCP request packet

技术图片

 - transaction ID is the same as the previous 2 (disover and offer) packets.

4) DHCP ACK

The server responds with a DHCP ACK message, confirming the requested parameters, and records that information in its database.

技术图片

- The client now has an IP address and can use it to begin communicating on the network.

In-Lease Renewal

A clients is allowed to use the IP adress for only a limited amount of time before it must renew the lease.

in-lease renewal: When a client with an IP address in-lease reboots, it performs truncated version of the DORA process (the discovery and offer packets are removed, leaving only request and acknowledgement) to reclaim its IP address.

DHCP

标签:each   war   connect   rgb   mit   nta   mini   out   traffic   

原文地址:https://www.cnblogs.com/RDaneelOlivaw/p/14780450.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!