DHCP中继实验

实验拓扑

image-20240115154834610

实验需求

  1. 按照图示搭建拓扑并配置IP地址

  2. 配置RTA为DHCP服务器,能够跨网段为192.168.20.0/24网段自动分配IP地址,要求分配DNS地址为8.8.8.8

  3. PC1获取地址后,能够访问到192.168.10.1

实验解析

1、配置IP地址

[RTA]int g0/0
[RTA-GigabitEthernet0/0]ip address 192.168.10.1 24

[SWA]int g1/0/1
[SWA-GigabitEthernet1/0/1]port link-mode route 
[SWA-GigabitEthernet1/0/1]ip address 192.168.10.2 24
[SWA-GigabitEthernet1/0/1]int g1/0/2
[SWA-GigabitEthernet1/0/2]port link-mode route
[SWA-GigabitEthernet1/0/2]ip address 192.168.20.254 24

2、配置RTA为DHCP服务器,能够跨网段为192.168.20.0/24网段自动分配IP地址,要求分配DNS地址为8.8.8.8

步骤1:在RTA上开启DHCP服务,创建地址池为1号,宣告网段192.168.20.0/24,网关地址为192.168.20.254,DNS服务器地址为8.8.8.8,配置一条静态默认路由指向192.168.10.2

[RTA]dhcp enable 
[RTA]dhcp server ip-pool 1
[RTA-dhcp-pool-1]network 192.168.20.0 24
[RTA-dhcp-pool-1]gateway-list 192.168.20.254
[RTA-dhcp-pool-1]dns-list 8.8.8.8
[RTA]ip route-static 0.0.0.0 0 192.168.10.2

步骤2:在SWA上开启DHCP功能,并在连接客户端的接口上开启DHCP中继功能,并指定DHCP服务器的IP地址

[SWA]dhcp enable 
[SWA]int g1/0/2
[SWA-GigabitEthernet1/0/2]dhcp select relay 
[SWA-GigabitEthernet1/0/2]dhcp relay server-address 192.168.10.1

3、PC1获取地址后,能够访问到192.168.10.1

步骤1:在RTA上通过display dhcp server ip-in-use命令查看下发的IP地址

[RTA]dis dhcp server ip-in-use 
IP address       Client identifier/    Lease expiration      Type
                 Hardware address
192.168.20.1     0035-3665-632e-3833-  Jan 16 16:14:40 2024  Auto(C)         
                 6439-2e30-3330-362d-                                       
                 4745-302f-302f-31  

步骤2:在PC1上查看获取的IP地址

image-20240115162425340

步骤3:在PC1上ping RTA的IP地址

<H3C>ping 192.168.10.1
Ping 192.168.10.1 (192.168.10.1): 56 data bytes, press CTRL_C to break
56 bytes from 192.168.10.1: icmp_seq=0 ttl=254 time=0.803 ms
56 bytes from 192.168.10.1: icmp_seq=1 ttl=254 time=0.709 ms
56 bytes from 192.168.10.1: icmp_seq=2 ttl=254 time=0.710 ms
56 bytes from 192.168.10.1: icmp_seq=3 ttl=254 time=0.678 ms
56 bytes from 192.168.10.1: icmp_seq=4 ttl=254 time=0.871 ms