DHCP relay service configuration case

Since the DHCP client obtains the IP address after obtaining the response from the DHCP server through the network broadcast message, the broadcast message cannot cross network segments. Therefore, when the client and server are not in the same network segment, a DHCP relay agent is needed.

Experimental topology

Insert picture description here

Purpose

R1 is used as a DHCP server, and R1 and R2 are used as relay services to realize PCs on different network segments to obtain addresses

1. Switch SW1 divides VLAN

[SW1]vlan batch 10 20    					##创建vlan10 20
[SW1]int e0/0/1								##进入接口e 0/0/1
[SW1-Ethernet0/0/1]port link-type access	##配置为access口
[SW1-Ethernet0/0/1]port default vlan 10		##将接口放到vlan10中
[SW1-Ethernet0/0/1]int e0/0/2
[SW1-Ethernet0/0/2]p l a
[SW1-Ethernet0/0/2]p d v 20
[SW1-Ethernet0/0/2]int e0/0/3
[SW1-Ethernet0/0/3]p l a
[SW1-Ethernet0/0/3]p d v 10
[SW1-Ethernet0/0/3]int e0/0/4
[SW1-Ethernet0/0/4]p l a
[SW1-Ethernet0/0/4]p d v 20
[SW1-Ethernet0/0/4]int g0/0/1
[SW1-GigabitEthernet0/0/1]port link-type trunk
[SW1-GigabitEthernet0/0/1]port trunk allow-pass vlan all

2. Router R1 configuration-interface IP, DHCP service, DHCP address pool, DHCP global interface, default route

接口IP地址配置
[R1]int g0/0/0
[R1-GigabitEthernet0/0/0]ip add 14.0.0.2 24
[R1-GigabitEthernet0/0/0]un sh
[R1-GigabitEthernet0/0/0]q

开启DHCP服务
[R1]dhcp enable

划分DHCP地址池DHCP15
[R1]ip pool DHCP15
[R1-ip-pool-DHCP15]network 15.0.0.0 mask 24
[R1-ip-pool-DHCP15]gateway-list 15.0.0.1
[R1-ip-pool-DHCP15]dns-list 8.8.8.8 2.2.2.2
[R1-ip-pool-DHCP15]q

划分DHCP地址池DHCPvlan10
[R1]ip pool DHCPvlan10
[R1-ip-pool-DHCPvlan10]dns-list 8.8.8.8 2.2.2.2
[R1-ip-pool-DHCPvlan10]network 192.168.10.0 mask 24
[R1-ip-pool-DHCPvlan10]gateway-list 192.168.10.1
[R1-ip-pool-DHCPvlan10]q

划分DHCP地址池DHCPvlan20
[R1]ip pool DHCPvlan20
[R1-ip-pool-DHCPvlan20]network 192.168.20.0 mask 24
[R1-ip-pool-DHCPvlan20]gateway-list 192.168.20.1
[R1-ip-pool-DHCPvlan20]dns-list 8.8.8.8 2.2.2.2

配置DHCP全局接口
[R1-ip-pool-DHCPvlan20]int g0/0/0
[R1-GigabitEthernet0/0/0]dhcp select global
[R1-GigabitEthernet0/0/0]q

默认路由
[R1]ip route-static 0.0.0.0 0.0.0.0 14.0.0.1

3. Router R2 configuration-interface IP, one-arm routing, DHCP service, DHCP relay, static routing

接口IP地址配置
[R2]int g0/0/0
[R2-GigabitEthernet0/0/0]ip add 12.0.0.1 24
[R2-GigabitEthernet0/0/0]un sh
[R2]int g0/0/2
[R2-GigabitEthernet0/0/0]ip add 14.0.0.1 24
[R2-GigabitEthernet0/0/0]un sh

接口IP地址配置之单臂路由
[R2]int g0/0/1
[R2-GigabitEthernet0/0/1]un sh
[R2-GigabitEthernet0/0/1]int g0/0/1.10
[R2-GigabitEthernet0/0/1.10]dot1q termination vid 10
[R2-GigabitEthernet0/0/1.10]ip add 192.168.10.1 24
[R2-GigabitEthernet0/0/1.10]arp broadcast enable
[R2-GigabitEthernet0/0/1.10]q
[R2]int g0/0/1.20
[R2-GigabitEthernet0/0/1.20]dot1q termination vid 20
[R2-GigabitEthernet0/0/1.20]ip add 192.168.20.1 24
[R2-GigabitEthernet0/0/1.20]arp broadcast enable
[R2-GigabitEthernet0/0/1.20]q

开启DHCP服务
[R2]dhcp enable

在接口下配置中继模式及中继模式指定接口IP地址
[R2]int g0/0/1.10
[R2-GigabitEthernet0/0/1.10]dhcp select relay
[R2-GigabitEthernet0/0/1.10]dhcp relay server-ip 14.0.0.2

在接口下配置中继模式及中继模式指定接口IP地址
[R2-GigabitEthernet0/0/1.10]int g0/0/1.20
[R2-GigabitEthernet0/0/1.20]dhcp select relay
[R2-GigabitEthernet0/0/1.20]dhcp relay server-ip 14.0.0.2
[R2-GigabitEthernet0/0/1.20]q

静态路由
[R2]ip route-static 15.0.0.0 24 12.0.0.2

4. Router R3 configuration-interface IP, DHCP service, DHCP relay, default route

接口IP地址配置
[R3]int g0/0/0
[R3-GigabitEthernet0/0/0]ip add 12.0.0.2 24
[R3-GigabitEthernet0/0/0]un sh
[R3-GigabitEthernet0/0/0]int g0/0/1
[R3-GigabitEthernet0/0/1]ip add 15.0.0.1 24
[R3-GigabitEthernet0/0/1]un sh
[R3-GigabitEthernet0/0/1]q

开启DHCP服务
[R3]dhcp enable

在接口下配置中继模式及中继模式指定接口IP地址
[R3]int g0/0/1
[R3-GigabitEthernet0/0/1]dhcp select relay
[R3-GigabitEthernet0/0/1]dhcp relay server-ip 14.0.0.2

默认路由
[R3]ip route-static 0.0.0.0 0.0.0.0 12.0.0.1

5. Test connectivity and packet capture analysis
Enter the command ipconfig /renew to get the host address
Insert picture description here

DHCP protocol messages can be seen in packet capture
Insert picture description here

At this point, the experiment is over, thanks for reading!

Guess you like

Origin blog.csdn.net/cenjeal/article/details/107018767