一、网络拓扑
要求:
- PC1从AR1上获取TCP/IP参数,在AR1上配置接口DHCP
- PC2和PC3都从AR3上获取TCP/IP参数,AR3配置全局DHCP
- 网段划分
视AR3为DHCP Server,由于服务器一般配置为静态IP,所以为AR3的g0/0/0接口配置静态IP地址:192.168.3.100,由于DHCP Server要给其他网段的主机提供TCP/IP参数,所以要配置网关,配置网关地址:192.168.3.254
- 路由器接口配置IP地址
#AR1
<Huawei>system-view
[Huawei]interface g0/0/0
[Huawei-GigabitEthernet0/0/0]ip address 192.168.1.254 24
[Huawei-GigabitEthernet0/0/0]interface g0/0/1
[Huawei-GigabitEthernet0/0/1]ip address 192.168.2.254 24
[Huawei-GigabitEthernet0/0/1]interface g0/0/2
[Huawei-GigabitEthernet0/0/2]ip address 172.16.10.1 24
#AR2
<Huawei>sys
[Huawei]int g0/0/2
[Huawei-GigabitEthernet0/0/2]ip add 192.168.3.254 24
[Huawei-GigabitEthernet0/0/2]int g0/0/0
[Huawei-GigabitEthernet0/0/0]ip add 172.16.10.2 24
#AR3
<Huawei>sys
[Huawei]int g0/0/0
[Huawei-GigabitEthernet0/0/0]ip add 192.168.3.100 24
[Huawei-GigabitEthernet0/0/0]quit
[Huawei]ip route-static 0.0.0.0 0 192.168.3.254
二、路由器基于接口的DHCP
#在路由器AR1的接口g0/0/0配置接口DHCP
[Huawei]dhcp enable #开启DHCP
[Huawei]int g0/0/0
[Huawei-GigabitEthernet0/0/0]dhcp select interface
[Huawei-GigabitEthernet0/0/0]dhcp server dns-list 114.114.114.114 8.8.8.8
此时PC1可以从路由器AR1的g0/0/0接口获取TCP/IP参数:
三、路由器基于全局的DHCP
#AR3
<Huawei>sys
[Huawei]dhcp enable
[Huawei]ip pool LAN3 #定义IP地址池,名称为LAN3
[Huawei-ip-pool-LAN3]network 192.168.3.0 mask 24 #指定网段
[Huawei-ip-pool-LAN3]gateway-list 192.168.3.254 #指定网关
[Huawei-ip-pool-LAN3]dns-list 114.114.114.114 8.8.8.8 #指定DNS
[Huawei-ip-pool-LAN3]quite
[Huawei]ip pool LAN2
[Huawei-ip-pool-LAN2]network 192.168.2.0 mask 24
[Huawei-ip-pool-LAN2]gateway-list 192.168.2.254
[Huawei-ip-pool-LAN2]dns-list 114.114.114.114 8.8.8.8
#进入接口开启全局DHCP
[Huawei]int g0/0/0
[Huawei-GigabitEthernet0/0/0]dhcp select global
此时PC3可以从路由器AR3获取TCP/IP参数:
四、路由器配置DHCP中继代理
由于PC2发送DHCP Discover报文不能到达DHCP Server,所以需要在AR1配置DHCP中继代理
[Huawei]dhcp enable
[Huawei]int g0/0/1
[Huawei-GigabitEthernet0/0/1]dhcp select relay #开启DHCP中继
[Huawei-GigabitEthernet0/0/1]dhcp relay server-ip 192.168.3.100 #指定DHCP服务器IP地址
- 配置路由
由于AR1不能把中继报文转到DHCP Server,所以需要配置路由,同样在AR2上配置回包的路由
#AR1配置路由
[Huawei]ip route-static 192.168.3.100 32 172.16.10.2
#AR2配置路由
[Huawei]ip route-static 192.168.2.0 24 172.16.10.1