LSW1配置:
<Huawei>sys
[Huawei]sys LS1
[LS1]v b 10 20
[LS1]int e0/0/1
[LS1-Ethernet0/0/1]port link-type access //端口链路类型访问
[LS1-Ethernet0/0/1]port default vlan 10 //端口默认 vlan 10
[LS1-Ethernet0/0/1]un sh
[LS1-Ethernet0/0/1]int e0/0/2
[LS1-Ethernet0/0/2]port link-type access //端口链路类型访问
[LS1-Ethernet0/0/2]port default vlan 20 //端口默认 vlan 20
[LS1-Ethernet0/0/2]un sh
[LS1-Ethernet0/0/2]int e0/0/3
[LS1-Ethernet0/0/3]port link-type access //端口链路类型访问
[LS1-Ethernet0/0/3]port default vlan 10 //端口默认 vlan 10
[LS1-Ethernet0/0/3]un sh
[LS1-Ethernet0/0/3]int e0/0/4
[LS1-Ethernet0/0/4]port link-type access //端口链路类型访问
[LS1-Ethernet0/0/4]port default vlan 20 //端口默认 vlan 20
[LS1-Ethernet0/0/4]int g0/0/1
[LS1-GigabitEthernet0/0/1]port link-type trunk //端口链路类型中继
[LS1-GigabitEthernet0/0/1]port trunk allow-pass vlan 10 20 //端口中继允许通过vlan 10 20
[LS1-GigabitEthernet0/0/1]un sh
R1配置:
<Huawei>sys
[Huawei]sysname R1
[R1]dhcp enable //dhcp启用
[R1]int g0/0/1.10
[R1-GigabitEthernet0/0/1.10]dot1q termination vid 10 //dot1q终止vid10
[R1-GigabitEthernet0/0/1.10]ip add 192.168.10.1 24 //ip 添加 192.168.10.1 24
[R1-GigabitEthernet0/0/1.10]arp broadcast enable //arp 广播启用
[R1-GigabitEthernet0/0/1.10]un sh
[R1-GigabitEthernet0/0/1.10]dhcp select relay
[R1-GigabitEthernet0/0/1.10]dhcp relay server-ip 14.0.0.2 //dhcp中继服务器-ip 14.0.0.2
[R1-GigabitEthernet0/0/1.10]un sh
[R1-GigabitEthernet0/0/1.10]q
[R1-GigabitEthernet0/0/1.10]int g0/0/1.20
[R1-GigabitEthernet0/0/1.20]dot1q termination vid 20 //dot1q终止vid20
[R1-GigabitEthernet0/0/1.20]ip add 192.168.20.1 24 //ip 添加 192.168.20.1 24
[R1-GigabitEthernet0/0/1.20]arp broadcast enable //arp 广播启用
[R1-GigabitEthernet0/0/1.20]un sh
[R1-GigabitEthernet0/0/1.20]dhcp select relay
[R1-GigabitEthernet0/0/1.20]dhcp relay server-ip 14.0.0.2 //dhcp中继服务器-ip 14.0.0.2
[R1-GigabitEthernet0/0/1.20]un sh
[R1-GigabitEthernet0/0/1.20]q
[R1]int g0/0/2
[R1-GigabitEthernet0/0/2]ip add 14.0.0.1 24
[R1-GigabitEthernet0/0/2]un sh
[R1-GigabitEthernet0/0/2]int g0/0/0
[R1-GigabitEthernet0/0/0]ip add 12.0.0.1 24
[R1-GigabitEthernet0/0/0]un sh
[R1-GigabitEthernet0/0/0]q
[R1]ip route-static 15.0.0.0 24 12.0.0.2 //配置静态路由
R2配置:
<Huawei>sys
[Huawei]sysname R2
[R2]int g0/0/0
[R2-GigabitEthernet0/0/0]ip add 12.0.0.2 24
[R2-GigabitEthernet0/0/0]un sh
[R2]dhcp enable
[R2]int g0/0/1
[R2-GigabitEthernet0/0/1]ip add 15.0.0.1 24
[R2-GigabitEthernet0/0/1]dhcp select relay
[R2-GigabitEthernet0/0/1]dhcp relay server-ip 14.0.0.2
[R2-GigabitEthernet0/0/1]q
[R2-GigabitEthernet0/0/1]un sh
[R2-GigabitEthernet0/0/1]q
[R2]ip route-static 0.0.0.0 0.0.0.0 12.0.0.1 配置默认路由
R3配置:
<Huawei>sys
[Huawei]sys R3
[R3]dhcp enable
[R3]int g0/0/0
[R3-GigabitEthernet0/0/0]ip add 14.0.0.2 24
[R3-GigabitEthernet0/0/0]un sh
[R3-GigabitEthernet0/0/0]dhcp select global //dhcp 选择全局
[R3-GigabitEthernet0/0/0]q
[R3]ip pool dhcp15
[R3-ip-pool-dhcp15]network 15.0.0.0 mask 24 //网络 15.0.0.0 掩码 24
[R3-ip-pool-dhcp15]gateway-list 15.0.0.1 //网关列表 15.0.0.1
[R3-ip-pool-dhcp15]dns-list 8.8.8.8 2.2.2.2
[R3-ip-pool-dhcp15]excluded-ip-address 15.0.0.100 15.0.0.254 //排除-ip 地址 15.0.0.100 15.0.0.254
[R3-ip-pool-dhcp15]static-bind ip-address 15.0.0.88 mac-address 5489-98B8-165E
//静态绑定 IP 地址 15.0.0.88 mac 地址 5489-98B8-165E
[R3-ip-pool-dhcp15]q
[R3]ip pool dhcpv10
[R3-ip-pool-dhcpv10]network 192.168.10.0 mask 24 //网络 192.168.10.0 掩码 24
[R3-ip-pool-dhcpv10]gateway-list 192.168.10.1 //网关列表 192.168.10.1
[R3-ip-pool-dhcpv10]dns-list 8.8.8.8 2.2.2.2
[R3-ip-pool-dhcpv10]q
[R3]ip pool dhcpv20
[R3-ip-pool-dhcpv20]network 192.168.20.0 mask 24
[R3-ip-pool-dhcpv20]gateway-list 192.168.20.1
[R3-ip-pool-dhcpv20]dns-list 8.8.8.8 2.2.2.2
[R3-ip-pool-dhcpv20]q
[R3]ip route-static 0.0.0.0 0.0.0.0 14.0.0.1 配置默认路由
5台PC将IPv4配置更改为DHCP 应用
点击命令行输入ipconfig /release 释放IP ipconfig /renew 获取IP
Ping下5台PC ip 是否互通