Ethernet DHCP (8 types of DHCP messages, DHCP configuration, DHCP relay)

2.14.1 Ethernet DHCP (8 types of DHCP messages, DHCP configuration, DHCP relay)

1. Eight types of DHCP messages

When DHCP works normally, it usually exchanges 4 types of messages (Discover, Offer, Request, ack), but when a fault occurs or a network parameter (address) conflict occurs, how should it be explained?

  • DHCP discovery (DHCP-Discover)

    • "Client" network-wide DHCP request, carrying flag information to determine whether to broadcast the offer reply

insert image description here

  • DHCP offer (DHCP-Offer)

    • "Server" receives the request and responds (unicast/broadcast) with configuration information

    insert image description here

  • DHCP request (DHCP-Request)

    • "Client" receives the server offer, and then replies to the server

insert image description here

  • DHCP acknowledgment (DHCP-ack)

    • "Server" replies to the known address received by the client

insert image description here

  • DHCP deny (DHCP-nak)

    • "Server" replied that the address cannot be allocated normally (the address pool is empty)
    • When the parameter selected by the client in the Request is incorrect or invalid , it will reply with a Nak message, and the client will re-apply after receiving the Nak.

insert image description here

  • DHCP release (DHCP-Release)

    • "Client" manually release the DHCP address
    • After receiving the Release packet actively sent by the client, the address information occupied by the client will be released.

insert image description here

  • DHCP information (DHCP-Inform)

    • "Client" already has an IP, and requests other information such as gateway and DNS separately.
    • At present, the Ethernet network is basically not used.

insert image description here

  • DHCP conflict (DHCP-Decline)

    • "Client" tells the server that there is a conflict in the offer address.
    • After receiving the Ack, the client uses the address to send out the address obtained by the ARP request (see if anyone uses this address). If there is a reply packet indicating that there is an address conflict with other hosts on the intranet, immediately send a Decline message to the DHCP server Apply for a new address (the server replies with a new address with an Ack message).

insert image description here

Two, DHCP configuration

Interface configuration:

dhcp enable
接口下:
	interface g0/0/1
    接口启用:dhcp select interface
    DNS列表:dhcp server dns-list 8.8.8.8 114.114.114.114
    租期时间:dhcp server lease day 1 hour 1 minunte 1
    固定地址:dhcp server static-bind ip-address <指定IP地址> macc-address <客户端MAC>
    排除地址:dhcp server excluded-ip-address <起始IP> <结束IP>
>>>默认下发地址从254开始下发,如果地址有冲突将跳过冲突地址

Global configuration:

dhcp enable
ip pool <地址池名称>
	network 192.168.1.0 mask 24
	gateway-list 192.168.1.254
	dns-list 8.8.8.8 114.114.114.114
	lease day 1 hour 1 minunte 1
	static-bind ip-address <指定IP地址> macc-address <客户端MAC>
	excluded-ip-address <起始IP> <结束IP>
接口下启用全局DHCP:
interface g0/0/1
	ip add 192.168.1.254 24
	dhcp select global	# 使用全局地址池,通过识别接口地址判断使用的地址池

3. DHCP relay

Building a centralized network service will cause the client and server to span multiple network segments.

The request message sent by the client is a broadcast message and cannot reach the server across the network segment (because the router isolates the broadcast).

Therefore, a "relay device" is required to help the client transmit message information.

Note: It is necessary to implement DHCP to deliver addresses to clients, and it is necessary to ensure that the DHCP server can communicate with the client's network.

That is: DHCP can access the client's network

insert image description here

Configuration example:

insert image description here

DHCP服务器配置:
[DHCP]dhcp enable
# 配置DHCP地址池信息
[DHCP]ip pool vlan1
[DHCP-ip-pool-vlan1]network 192.168.1.0 mask 24
[DHCP-ip-pool-vlan1]gateway-list 192.168.1.254
[DHCP-ip-pool-vlan1]dns-list 8.8.8.8 114.114.114.114
# 接口应用全局DHCP地址池
[DHCP]int g0/0/0
[DHCP-GigabitEthernet0/0/0]ip add 10.1.13.1 24
[DHCP-GigabitEthernet0/0/0]dhcp select global 
# 保障DHCP与客户端之间的通信
[DHCP]ip route-static 192.168.1.0 24 10.1.13.3

AR3中继服务器配置:
[AR3]dhcp enable 
[AR3]int g0/0/0
[AR3-GigabitEthernet0/0/0]ip add 10.1.13.3 24
[AR3-GigabitEthernet0/0/0]int g0/0/1
[AR3-GigabitEthernet0/0/1]ip add 192.168.1.254 24
[AR3-GigabitEthernet0/0/1]dhcp select relay 
[AR3-GigabitEthernet0/0/1]dhcp relay server-ip 10.1.13.1
[AR3-GigabitEthernet0/0/1]q
# 由于AR3与10.1.13.0网络是直连,不需要配置静态路由
[DHCP]

packet capture verification

  • After configuring the relay, capture packets on the G0/0/0 interface of the DHCP server to observe the interaction of DHCP-related packets:
    • It can be seen that 10.1.13.1 is received by the DHCP server 单播Discover报文, indicating that the relayed DHCP message is transmitted in unicast.

insert image description here

Guess you like

Origin blog.csdn.net/qq_45443704/article/details/128269107