1.R1和R2配置ip地址,并打通路由
R1
[Huawei-GigabitEthernet0/0/0]ip address 192.168.10.1 24
[Huawei]ip route-static 192.168.20.0 255.255.255.0 192.168.10.2
R2
[Huawei-GigabitEthernet0/0/0]ip address 192.168.10.2 24
[Huawei-GigabitEthernet0/0/1]ip address 192.168.20.1 24
[Huawei]ip route-static 0.0.0.0 0.0.0.0 192.168.10.1
2.R1配置DHCP服务
[Huawei-ip-pool-test]gateway-list 192.168.20.1
[Huawei-ip-pool-test]network 192.168.20.0 mask 255.255.255.0
[Huawei-ip-pool-test]dns-list 114.114.114.114
[Huawei]int g0/0/0
[Huawei-GigabitEthernet0/0/0]dhcp select global
3.R2配置DHCP中继,dhcp报文为广播报文,无法通过三层接口,所以dhcp中继需要在与终端连接的接口配置
[Huawei]dhcp enable
[Huawei-GigabitEthernet0/0/1]dhcp select relay
[Huawei-GigabitEthernet0/0/1]dhcp relay server-ip 192.168.10.1
[Huawei-GigabitEthernet0/0/1]dhcp select global
4.终端成功获取地址