7.DHCP Protocol Principles
7.DHCP Protocol Principles
7.DHCP Protocol Principles
⚫ Manually configuring IP addresses, masks, gateways and other parameters for a big number of hosts in a
LAN is tedious and error-prone.
⚫ DHCP (Dynamic Host Configuration Protocol) can centrally manage and allocate IP addresses so that
hosts in the network environment can dynamically obtain IP addresses, Gateway addresses, DNS server
addresses, and other information, and can improve the use of addresses while avoiding the problem of IP
address conflicts.
⚫ Laptops, desktop computers, cell phones, smart appliances and other devices are closely related to our
lives. But the basis of all these connections to the Internet is the IP address.
⚫ How to obtain IP address efficiently and securely with no perceived user experience?
Network 1 Network 2
⚫ DHCP client
➢ A host that needs to obtain an IP address dynamically.
⚫ DHCP server
➢ A DHCP-capable server or network device to assign IP addresses to clients and manages these IP addresses.
⚫ DHCP relay
➢ When a DHCP client and a DHCP server are not in a same subnet, they need a DHCP relay to forward DHCP
request and reply packets. Generally, it is a network device such as a router or a Layer 3 switch.
Network 1
Okay, I acknowledge!
DHCP-ACK
(Broadcast)
⚫ DHCP Discover
➢ This message is the first request message sent by the PC, it is a broadcast message, the main purpose is to
discover the DHCP server, but the PC does not know the IP address of DHCP, so the destination MAC and
destination IP address are broadcasts
⚫ DHCP Offer
➢ This message is the first message returned by the DHCP server, when there are multiple DHCP servers in the
network, the PC will only keep the DHCP Offer received first. DHCP Offer contains the IP address, gateway IP,
DNS parameters and other configuration information that the DHCP server can allocate to the PC
⚫ DHCP request
➢ The second request message from the PC, the PC initiates a formal request based on the information in the Offer
returned by the server.
⚫ DHCP ACK
➢ After the server receives the request message from the PC, it allocates the corresponding IP address from the
address pool and returns it to the PC
Network 1
The 192.168.1.2/24 you provided is already being used and I refuse to use it!
DHCP-Decline
I don't want to use the address you allocated, please give it to someone else
DHCP-Release
Network 1
Upon 50% I would like to continue using the IP address you allocated, is that OK?
DHCP-REQUEST
time of the
Ok, you can continue to use it
lease term DHCP-ACK
Upon I would like to continue using the IP address you allocated, is that OK?
DHCP-REQUEST
87.5% time
of the lease Ok, you can continue to use it
DHCP-ACK
term No, you can not continue to use it
DHCP-NAK
DHCP release Message to notify the server when a client releases an address
DHCP inform The client already has an IP address and requests more detailed configuration parameters
DHCP nak The server tells the client that the address request is incorrect or the lease period has expired
Ruijie(dhcp-config)# lease 1 0 0
Ruijie-SW(config)#service dhcp
Ruijie-SW(config)#ip dhcp pool IT
Ruijie-SW(dhcp-config)#network 172.16.1.0 255.255.255.0
Ruijie-SW(dhcp-config)#default-router 172.16.1.254
Ruijie-SW(dhcp-config)#dns-server 114.114.114.114 8.8.8.8
Ruijie-SW(dhcp-config)#lease 0 8 0
Ruijie-SW(dhcp-config)#exit
⚫ DHCP Client and DHCP Server are not in the same network segment, DHCP broadcast messages are not reachable,
then you need to deploy DHCP Relay devices.
⚫ To ensure IP/route reachability between the gateway device acting as a DHCP relay and the DHCP server.
Network 1 Network 2
⚫ In the same VLAN, if there is a malicious user who has set up a DHCP server privately, then it will make
the users in this VLAN obtain the wrong IP address, resulting in the inability to access the network.
Core Switch
DHCP Server
offer messgae
Gi0/28
Gi0/1
discover message
request message
PC1 PC2
Oh no, I can't get on the internet~
Gi0/22
Gi0/22
Access Switch
PC1 PC2
⚫ The DHCP Snooping table entry can be deleted in the following way:
➢ Recorded lease time expires (successful renewal will not be deleted) Core Switch
DHCP Server
➢ Snooping on legitimate DHCP-RELEASE/DHCP-DECLINE messages sent
Gi0/28
by the client
➢ When a NAK message is received from the TRUST port (meaning that the Rogue DHCP Server
address in the offer is not available) Gi0/22
➢ When a user actively deletes a binding record using the clear command Access Switch
Gi0/22
Ruijie#clear ip dhcp snooping binding [A.B.C.D | H.H.H | interface | vlan | <cr>] Gi0/22
Gi0/1
PC1 PC2
➢ If they are the same, continue to forward it, if not, discard the Request
message
Gi0/22
Gi0/22
Access Switch
Gi0/1 Gi0/22
RogueDHCP
Rogue DHCPServer
Server
PC1 PC2
⚫ DHCP snooping can only snoop non-relay DHCP messages, if there is a relay in the network, the following
configuration should be done in the global mode of the device configured with DHCP snooping (the giaddr field in the
DHCP message indicates the IP address of the first relay device through which the discover message passes):
Ruijie(config)#ip dhcp snooping check-giaddr
⚫ The port on which DHCP Snooping comes into effect can be a wired switch port, a Layer 2 AP port, or a Layer 2
encapsulation subinterface.
⚫ DHCP Snooping and DHCP Relay are not supported for simultaneous deployment in VRF scenarios;
⚫ When DHCP Snooping loose forwarding is enabled, if the DHCP Snooping binding table is full, the new user DHCP
messages can continue to be forwarded to get the address, but DHCP Snooping will not record the binding table
entries of the new user. If not turned on, IP addresses cannot be obtained after the table entry reaches full capacity.
The enabling commands are as follows:
1. The terminal obtains an IP address through DHCP, and the server finally determines in which message ()
is the information such as IP address and mask provided to the terminal included?
A. DHCP Discover message
B. DHCP Offer message
C. DHCP Request message B
2. The DHCP Snooping feature creates DHCP Snooping Binding table entries by snooping which DHCP
message ()?
A. DHCP Discover message
B. DHCP Offer message
C. DHCP Request message D
1. (Multiple Choice) An access switch that has deployed DHCP Snooping maintains a DHCP Snooping
Binding table, under what circumstances will the binding entries be deleted ()?
A. Terminal DHCP lease expires
B. Snooping on legitimate DHCP-RELEASE/DHCP-DECLINE messages sent by the client
C. Receives a NAK message from the TRUST port
D. User initiated deletion of Binding records using the clear command
ABCD
⚫ This chapter mainly introduces the application scenarios of DHCP service, the working principle of DHCP
protocol, message types, message structure, and the basic configuration and relay mode of DHCP.
⚫ After DHCP Snooping is enabled on the access switch, all interfaces will be set to Untrust state, and the
ports connected to DHCP server will be manually configured as Trust interfaces, and Untrust interfaces
will discard all DHCP Offer messages and DHCP ACK messages, which can prevent illegal DHCP
servers from accessing the network.
⚫ The DHCP Snooping function will snoop the DHCP Offer message received by the trust interface, extract
the client IP address, client MAC address, and lease time fields in the message, combine with the port
number and VLAN where the client side is recorded by the device, generate a Binding record, and
provide raw data for other security function modules to realize further access security functions.