DHCP stands for Dynamic Host Configuration Protocol. As its name suggests DHCP is used to provide configuration like Ip Address, Network Mask, DNS, Proxy, Bootp, Default Gateway, etc. to the host. But the most know and popular usage are distributing IP addresses. There is a broad range of DHCP usage scenarios. In this tutorial, we will look at the IP address distribution of DHCP with an example.
DHCP代表动态主机配置协议。 顾名思义,DHCP用于为主机提供IP地址,网络掩码,DNS,代理,Bootp,默认网关等配置。 但是,最广为人知的用法是分配IP地址。 DHCP的使用方案范围很广。 在本教程中,我们将通过一个示例来了解DHCP的IP地址分布。
DHCP租用阶段 (DHCP Lease Phases)
DHCP IP address assignment is done in 4 steps where all steps will be examined below. DHCP uses UDP packets which means connectionless architecture. DHCP works as a client-server architecture. The client initiate the process. Some times clients may be residing in the different networks so to transmit DHCP packet a DHCP Helper or DHCP Relay needed in the client network.
DHCP IP地址分配分为4个步骤,下面将检查所有步骤。 DHCP使用UDP数据包,这意味着无连接架构。 DHCP作为客户端-服务器体系结构。 客户端启动该过程。 有时,客户端可能位于不同的网络中,以便在客户端网络中传输DHCP数据包,DHCP帮助程序或DHCP中继。
DHCP实验环境(DHCP Lab Environment)
We will use Gns3 as lab environment. There will be also a DHCP server which is Pfsense and a DHCP client Windows Server 2012. We will enable DHCP service of Pfsense and than capture the DHCP traffic with Wireshark.
我们将使用Gns3作为实验室环境。 还将有一个DHCP服务器Pfsense和一个DHCP客户端Windows Server2012。我们将启用Pfsense的DHCP服务,然后使用Wireshark捕获DHCP流量。
启用DHCP服务(Enable DHCP Service)
DHCP service configuration screen can be accessed like below.
可以如下访问DHCP服务配置屏幕。
Services -> DHCP Server
Services -> DHCP Server
Click to the Enable DHCP server on LAN interface
.And then set IP address range. In this example we will use 10.0.0.128
and 10.0.0.254
. To start DHCP service with specified configuration click Save
button on the bottom of the page.
单击“ Enable DHCP server on LAN interface
。然后设置IP地址范围。 在此示例中,我们将使用10.0.0.128
和10.0.0.254
。 要以指定的配置启动DHCP服务,请单击页面底部的“ Save
按钮。
DHCP发现步骤和软件包(DHCP Discovery Step and Package)
Following screenshot shows everything about discovery packet sent from client. Client simply send broadcast packet to get an offer from DHCP server currently serves for this network.
以下屏幕截图显示了有关从客户端发送的发现数据包的所有信息。 客户端只需发送广播数据包即可从当前为该网络服务的DHCP服务器获得报价。
DHCP提供步骤和打包(DHCP Offer Step and Package)
DHCP server listening to the network of the currently requested client and provides an offer to this client. Offered IP address is 10.0.0.128 and lease time is 2 hours. The lease time is to set expire time for a given IP address. After the lease time is timed out client will re-request the same IP address automatically.
DHCP服务器侦听当前请求的客户端的网络,并为此客户端提供要约。 提供的IP地址是10.0.0.128,租用时间是2小时。 租用时间用于设置给定IP地址的到期时间。 租约时间超时后,客户端将自动重新请求相同的IP地址。
DHCP请求步骤和打包(DHCP Request Step and Package)
The client will get the offer and in most situations, the client will accept offered IP address and network configuration. As we see the client also sends its hostname with hostname Option 12.
客户将获得报价,并且在大多数情况下,客户将接受提供的IP地址和网络配置。 如我们所见,客户端还发送其主机名和主机名Option 12。
DHCP确认步骤和程序包(DHCP Acknowledge Step and Package)
After the server gets the response from the client it will assign the offered IP address to this client and allocate this IP. This IP will not be offered to new clients if it is not freed.
服务器从客户端获得响应后,它将为该客户端分配提供的IP地址并分配该IP。 如果未释放该IP,则不会将其提供给新客户。