二层配置
(1)配置SW3、SW4、SW5、SW6与PC和交换机相连的接口
##SW3 vlan batch 1 to 5 interface GigabitEthernet0/0/1 port link-type trunk port trunk allow-pass vlan 2 to 5 # interface GigabitEthernet0/0/2 port link-type trunk port trunk allow-pass vlan 2 to 5 # interface Ethernet0/0/1 port link-type access port default vlan 5 # stp region-configuration region-name Huawei instance 1 vlan 1 to 5 instance 2 vlan 6 to 10 instance 3 vlan 11 to 15 instance 4 vlan 16 to 20 active region-configuration # ##sw4 vlan batch 6 to 10 interface GigabitEthernet0/0/1 port link-type trunk undo port trunk allow-pass vlan 1 port trunk allow-pass vlan 6 to 10 # interface GigabitEthernet0/0/2 port link-type trunk undo port trunk allow-pass vlan 1 port trunk allow-pass vlan 6 to 10 # interface Ethernet0/0/1 port link-type access port default vlan 6 # stp region-configuration region-name Huawei instance 1 vlan 1 to 5 instance 2 vlan 6 to 10 instance 3 vlan 11 to 15 instance 4 vlan 16 to 20 active region-configuration # #####SW5 vlan batch 11 to 15 # interface Ethernet0/0/1 port link-type access port default vlan 15 # interface GigabitEthernet0/0/1 port link-type trunk undo port trunk allow-pass vlan 1 port trunk allow-pass vlan 11 to 15 # interface GigabitEthernet0/0/2 port link-type trunk undo port trunk allow-pass vlan 1 port trunk allow-pass vlan 11 to 15 # stp region-configuration region-name Huawei instance 1 vlan 1 to 5 instance 2 vlan 6 to 10 instance 3 vlan 11 to 15 instance 4 vlan 16 to 20 active region-configuration ###SW6 vlan batch 16 to 20 # interface GigabitEthernet0/0/1 port link-type trunk undo port trunk allow-pass vlan 1 port trunk allow-pass vlan 16 to 20 # interface GigabitEthernet0/0/2 port link-type trunk undo port trunk allow-pass vlan 1 port trunk allow-pass vlan 16 to 20 # interface Ethernet0/0/1 port link-type access port default vlan 20 # stp region-configuration region-name Huawei instance 1 vlan 1 to 5 instance 2 vlan 6 to 10 instance 3 vlan 11 to 15 instance 4 vlan 16 to 20 active region-configuration # #####SW1 vlan batch 2 to 20 103 to 104 # stp region-configuration region-name Huawei instance 1 vlan 1 to 5 instance 2 vlan 6 to 10 instance 3 vlan 11 to 15 instance 4 vlan 16 to 20 active region-configuration ## stp instance 1 root primary stp instance 2 root primary stp instance 3 root secondary stp instance 4 root secondary # # interface GigabitEthernet0/0/1 port link-type trunk port trunk allow-pass vlan 2 to 5 # interface GigabitEthernet0/0/2 port link-type trunk undo port trunk allow-pass vlan 1 port trunk allow-pass vlan 16 to 20 # interface GigabitEthernet0/0/3 port link-type trunk undo port trunk allow-pass vlan 1 port trunk allow-pass vlan 6 to 10 # interface GigabitEthernet0/0/4 port link-type trunk undo port trunk allow-pass vlan 1 port trunk allow-pass vlan 11 to 15 # # interface GigabitEthernet0/0/21 port link-type access port default vlan 103 # interface GigabitEthernet0/0/22 port link-type access port default vlan 104 #####SW2 vlan batch 2 to 20 203 to 204 # stp instance 1 root secondary stp instance 2 root secondary stp instance 3 root primary stp instance 4 root primary stp region-configuration region-name Huawei instance 1 vlan 1 to 5 instance 2 vlan 6 to 10 instance 3 vlan 11 to 15 instance 4 vlan 16 to 20 active region-configuration # interface GigabitEthernet0/0/1 port link-type trunk port trunk allow-pass vlan 2 to 5 # interface GigabitEthernet0/0/2 port link-type trunk undo port trunk allow-pass vlan 1 port trunk allow-pass vlan 16 to 20 # interface GigabitEthernet0/0/3 port link-type trunk undo port trunk allow-pass vlan 1 port trunk allow-pass vlan 6 to 10 # interface GigabitEthernet0/0/4 port link-type trunk undo port trunk allow-pass vlan 1 port trunk allow-pass vlan 11 to 15 # interface GigabitEthernet0/0/21 port link-type access port default vlan 203 # interface GigabitEthernet0/0/22 port link-type access port default vlan 204
(2)Eth-Trunk
G0/0/23和G0/0/24 作为Eth-Trunk1的成员接口。 Eth-Trunk1接口作为Trunk链路,允许vlan1-20通过,在SW1和SW2上做Eth-Trunk1 接口,将G0/0/23 和G0/0/24 添加到 Eth-Trunk1
##SW1 interface Eth-Trunk1 mode lacp-static trunkport GigabitEthernet 0/0/23 to 0/0/24 port link-type trunk port trunk allow-pass vlan 2 to 20 ##SW2 interface Eth-Trunk1 mode lacp-static trunkport GigabitEthernet 0/0/23 to 0/0/24 port link-type trunk port trunk allow-pass vlan 2 to 20
(3)交换机的三层配置(vlanif vrrp)
###SW1 interface Vlanif1 ip address 192.168.1.253 255.255.255.0 vrrp vrid 1 virtual-ip 192.168.1.254 vrrp vrid 1 priority 120 vrrp vrid 1 preempt-mode timer delay 20 # interface Vlanif2 ip address 192.168.2.253 255.255.255.0 vrrp vrid 1 virtual-ip 192.168.2.254 vrrp vrid 1 priority 120 vrrp vrid 1 preempt-mode timer delay 20 # interface Vlanif3 ip address 192.168.3.253 255.255.255.0 vrrp vrid 1 virtual-ip 192.168.3.254 vrrp vrid 1 priority 120 vrrp vrid 1 preempt-mode timer delay 20 # interface Vlanif4 ip address 192.168.4.253 255.255.255.0 vrrp vrid 1 virtual-ip 192.168.4.254 vrrp vrid 1 priority 120 vrrp vrid 1 preempt-mode timer delay 20 # interface Vlanif5 ip address 192.168.5.253 255.255.255.0 vrrp vrid 1 virtual-ip 192.168.5.254 vrrp vrid 1 priority 120 vrrp vrid 1 preempt-mode timer delay 20 # interface Vlanif6 ip address 192.168.6.253 255.255.255.0 vrrp vrid 1 virtual-ip 192.168.6.254 vrrp vrid 1 priority 120 vrrp vrid 1 preempt-mode timer delay 20 # interface Vlanif7 ip address 192.168.7.253 255.255.255.0 vrrp vrid 1 virtual-ip 192.168.7.254 vrrp vrid 1 priority 120 vrrp vrid 1 preempt-mode timer delay 20 # interface Vlanif8 ip address 192.168.8.253 255.255.255.0 vrrp vrid 1 virtual-ip 192.168.8.254 vrrp vrid 1 priority 120 vrrp vrid 1 preempt-mode timer delay 20 # interface Vlanif9 ip address 192.168.9.253 255.255.255.0 vrrp vrid 1 virtual-ip 192.168.9.254 vrrp vrid 1 priority 120 vrrp vrid 1 preempt-mode timer delay 20 # interface Vlanif10 ip address 192.168.10.253 255.255.255.0 vrrp vrid 1 virtual-ip 192.168.10.254 vrrp vrid 1 priority 120 vrrp vrid 1 preempt-mode timer delay 20 # interface Vlanif11 ip address 192.168.11.252 255.255.255.0 vrrp vrid 2 virtual-ip 192.168.11.254 # interface Vlanif12 ip address 192.168.12.252 255.255.255.0 vrrp vrid 2 virtual-ip 192.168.12.254 # interface Vlanif13 ip address 192.168.13.252 255.255.255.0 vrrp vrid 2 virtual-ip 192.168.13.254 # interface Vlanif14 ip address 192.168.14.252 255.255.255.0 vrrp vrid 2 virtual-ip 192.168.14.254 # interface Vlanif15 ip address 192.168.15.252 255.255.255.0 vrrp vrid 2 virtual-ip 192.168.15.254 # interface Vlanif16 ip address 192.168.16.252 255.255.255.0 vrrp vrid 2 virtual-ip 192.168.16.254 # interface Vlanif17 ip address 192.168.17.252 255.255.255.0 vrrp vrid 2 virtual-ip 192.168.17.254 # interface Vlanif18 ip address 192.168.18.252 255.255.255.0 vrrp vrid 2 virtual-ip 192.168.18.254 # interface Vlanif19 ip address 192.168.19.252 255.255.255.0 vrrp vrid 2 virtual-ip 192.168.19.254 # interface Vlanif20 ip address 192.168.20.252 255.255.255.0 vrrp vrid 2 virtual-ip 192.168.20.254 # interface Vlanif103 ip address 13.1.1.1 255.255.255.0 # interface Vlanif104 ip address 14.1.1.1 255.255.255.0 # ####SW2 # interface Vlanif1 ip address 192.168.1.252 255.255.255.0 vrrp vrid 1 virtual-ip 192.168.1.254 # interface Vlanif2 ip address 192.168.2.252 255.255.255.0 vrrp vrid 1 virtual-ip 192.168.2.254 # interface Vlanif3 ip address 192.168.3.252 255.255.255.0 vrrp vrid 1 virtual-ip 192.168.3.254 # interface Vlanif4 ip address 192.168.4.252 255.255.255.0 vrrp vrid 1 virtual-ip 192.168.4.254 # interface Vlanif5 ip address 192.168.5.252 255.255.255.0 vrrp vrid 1 virtual-ip 192.168.5.254 # interface Vlanif6 ip address 192.168.6.252 255.255.255.0 vrrp vrid 1 virtual-ip 192.168.6.254 # interface Vlanif7 ip address 192.168.7.252 255.255.255.0 vrrp vrid 1 virtual-ip 192.168.7.254 # interface Vlanif8 ip address 192.168.8.252 255.255.255.0 vrrp vrid 1 virtual-ip 192.168.8.254 # interface Vlanif9 ip address 192.168.9.252 255.255.255.0 vrrp vrid 1 virtual-ip 192.168.9.254 # interface Vlanif10 ip address 192.168.10.252 255.255.255.0 vrrp vrid 1 virtual-ip 192.168.10.254 # interface Vlanif11 ip address 192.168.11.253 255.255.255.0 vrrp vrid 2 virtual-ip 192.168.11.254 vrrp vrid 2 priority 120 vrrp vrid 2 preempt-mode timer delay 20 # interface Vlanif12 ip address 192.168.12.253 255.255.255.0 vrrp vrid 2 virtual-ip 192.168.12.254 vrrp vrid 2 priority 120 vrrp vrid 2 preempt-mode timer delay 20 # interface Vlanif13 ip address 192.168.13.253 255.255.255.0 vrrp vrid 2 virtual-ip 192.168.13.254 vrrp vrid 2 priority 120 vrrp vrid 2 preempt-mode timer delay 20 # interface Vlanif14 ip address 192.168.14.253 255.255.255.0 vrrp vrid 2 virtual-ip 192.168.14.254 vrrp vrid 2 priority 120 vrrp vrid 2 preempt-mode timer delay 20 # interface Vlanif15 ip address 192.168.15.253 255.255.255.0 vrrp vrid 2 virtual-ip 192.168.15.254 vrrp vrid 2 priority 120 vrrp vrid 2 preempt-mode timer delay 20 # interface Vlanif16 ip address 192.168.16.253 255.255.255.0 vrrp vrid 2 virtual-ip 192.168.16.254 vrrp vrid 2 priority 120 vrrp vrid 2 preempt-mode timer delay 20 # interface Vlanif17 ip address 192.168.17.253 255.255.255.0 vrrp vrid 2 virtual-ip 192.168.17.254 vrrp vrid 2 priority 120 vrrp vrid 2 preempt-mode timer delay 20 # interface Vlanif18 ip address 192.168.18.253 255.255.255.0 vrrp vrid 2 virtual-ip 192.168.18.254 vrrp vrid 2 priority 120 vrrp vrid 2 preempt-mode timer delay 20 # interface Vlanif19 ip address 192.168.19.253 255.255.255.0 vrrp vrid 2 virtual-ip 192.168.19.254 vrrp vrid 2 priority 120 vrrp vrid 2 preempt-mode timer delay 20 # interface Vlanif20 ip address 192.168.20.253 255.255.255.0 vrrp vrid 2 virtual-ip 192.168.20.254 vrrp vrid 2 priority 120 vrrp vrid 2 preempt-mode timer delay 20 # interface Vlanif203 ip address 23.1.1.2 255.255.255.0 # interface Vlanif204 ip address 24.1.1.2 255.255.255.0 #
用PYthon工具代码如下 # VRRP SW1 1 vlanif1-10--- Master 2 vlanif11-20--- Backup # SW2 1 vlanif1-10--- Backup 2 vlanif11-20--- Master ###SW1(master) for i in range(1,11): print(f"interface vlanif {i}") print(f"ip address 192.168.{i}.253 24") print(f"vrrp vrid 1 virtual-ip 192.168.{i}.254") print(f"vrrp vrid 1 priority 120") print(f"vrrp vrid 1 preempt timer delay 20") print() ####SW1(backup) for i in range(11,21): print(f"interface vlanif {i}") print(f"ip address 192.168.{i}.253 24") print(f"vrrp vrid 2 virtual-ip 192.168.{i}.254") print() ####SW2(backup) for i in range(1,11): print(f"interface vlanif {i}") print(f"ip address 192.168.{i}.253 24") print(f"vrrp vrid 1 virtual-ip 192.168.{i}.254") print() ####SW2(master) for i in range(11,21): print(f"interface vlanif {i}") print(f"ip address 192.168.{i}.253 24") print(f"vrrp vrid 2 virtual-ip 192.168.{i}.254") print(f"vrrp vrid 2 priority 120") print(f"vrrp vrid 2 preempt timer delay 20") print()
[SW1]dis vrrp b VRID State Interface Type Virtual IP ---------------------------------------------------------------- 1 Master Vlanif1 Normal 192.168.1.254 1 Master Vlanif2 Normal 192.168.2.254 1 Master Vlanif3 Normal 192.168.3.254 1 Master Vlanif4 Normal 192.168.4.254 1 Master Vlanif5 Normal 192.168.5.254 1 Master Vlanif6 Normal 192.168.6.254 1 Master Vlanif7 Normal 192.168.7.254 1 Master Vlanif8 Normal 192.168.8.254 1 Master Vlanif9 Normal 192.168.9.254 1 Master Vlanif10 Normal 192.168.10.254 2 Backup Vlanif11 Normal 192.168.11.254 2 Backup Vlanif12 Normal 192.168.12.254 2 Backup Vlanif13 Normal 192.168.13.254 2 Backup Vlanif14 Normal 192.168.14.254 2 Backup Vlanif15 Normal 192.168.15.254 2 Backup Vlanif16 Normal 192.168.16.254 2 Backup Vlanif17 Normal 192.168.17.254 2 Backup Vlanif18 Normal 192.168.18.254 2 Backup Vlanif19 Normal 192.168.19.254 2 Backup Vlanif20 Normal 192.168.20.254 ---------------------------------------------------------------- Total:20 Master:10 Backup:10 Non-active:0 [SW1]
[SW2]dis vrrp b VRID State Interface Type Virtual IP ---------------------------------------------------------------- 1 Backup Vlanif1 Normal 192.168.1.254 1 Backup Vlanif2 Normal 192.168.2.254 1 Backup Vlanif3 Normal 192.168.3.254 1 Backup Vlanif4 Normal 192.168.4.254 1 Backup Vlanif5 Normal 192.168.5.254 1 Backup Vlanif6 Normal 192.168.6.254 1 Backup Vlanif7 Normal 192.168.7.254 1 Backup Vlanif8 Normal 192.168.8.254 1 Backup Vlanif9 Normal 192.168.9.254 1 Backup Vlanif10 Normal 192.168.10.254 2 Master Vlanif11 Normal 192.168.11.254 2 Master Vlanif12 Normal 192.168.12.254 2 Master Vlanif13 Normal 192.168.13.254 2 Master Vlanif14 Normal 192.168.14.254 2 Master Vlanif15 Normal 192.168.15.254 2 Master Vlanif16 Normal 192.168.16.254 2 Master Vlanif17 Normal 192.168.17.254 2 Master Vlanif18 Normal 192.168.18.254 2 Master Vlanif19 Normal 192.168.19.254 2 Master Vlanif20 Normal 192.168.20.254 ---------------------------------------------------------------- Total:20 Master:10 Backup:10 Non-active:0
(4)路由部分
[1]默认路由
# SW1 ip route-static 0.0.0.0 0.0.0.0 vlanif 103 13.1.1.3 ip route-static 0.0.0.0 0.0.0.0 vlanif 104 14.1.1.4 preference 100 # SW2 ip route-static 0.0.0.0 0.0.0.0 vlanif 204 24.1.1.4 ip route-static 0.0.0.0 0.0.0.0 vlanif 203 23.1.1.3 preference 100
[AR1]的回程路由
# AR1回程路由 ip route-static 192.168.1.0 24 G0/0/0 13.1.1.1 ip route-static 192.168.1.0 24 G0/0/1 23.1.1.2 preference 100 ip route-static 192.168.2.0 24 G0/0/0 13.1.1.1 ip route-static 192.168.2.0 24 G0/0/1 23.1.1.2 preference 100 ip route-static 192.168.3.0 24 G0/0/0 13.1.1.1 ip route-static 192.168.3.0 24 G0/0/1 23.1.1.2 preference 100 ip route-static 192.168.4.0 24 G0/0/0 13.1.1.1 ip route-static 192.168.4.0 24 G0/0/1 23.1.1.2 preference 100 ip route-static 192.168.5.0 24 G0/0/0 13.1.1.1 ip route-static 192.168.5.0 24 G0/0/1 23.1.1.2 preference 100 ip route-static 192.168.6.0 24 G0/0/0 13.1.1.1 ip route-static 192.168.6.0 24 G0/0/1 23.1.1.2 preference 100 ip route-static 192.168.7.0 24 G0/0/0 13.1.1.1 ip route-static 192.168.7.0 24 G0/0/1 23.1.1.2 preference 100 ip route-static 192.168.8.0 24 G0/0/0 13.1.1.1 ip route-static 192.168.8.0 24 G0/0/1 23.1.1.2 preference 100 ip route-static 192.168.9.0 24 G0/0/0 13.1.1.1 ip route-static 192.168.9.0 24 G0/0/1 23.1.1.2 preference 100 ip route-static 192.168.10.0 24 G0/0/0 13.1.1.1 ip route-static 192.168.10.0 24 G0/0/1 23.1.1.2 preference 100 ip route-static 192.168.11.0 24 G0/0/1 23.1.1.2 ip route-static 192.168.11.0 24 G0/0/0 13.1.1.1 preference 100 ip route-static 192.168.12.0 24 G0/0/1 23.1.1.2 ip route-static 192.168.12.0 24 G0/0/0 13.1.1.1 preference 100 ip route-static 192.168.13.0 24 G0/0/1 23.1.1.2 ip route-static 192.168.13.0 24 G0/0/0 13.1.1.1 preference 100 ip route-static 192.168.14.0 24 G0/0/1 23.1.1.2 ip route-static 192.168.14.0 24 G0/0/0 13.1.1.1 preference 100 ip route-static 192.168.15.0 24 G0/0/1 23.1.1.2 ip route-static 192.168.15.0 24 G0/0/0 13.1.1.1 preference 100 ip route-static 192.168.16.0 24 G0/0/1 23.1.1.2 ip route-static 192.168.16.0 24 G0/0/0 13.1.1.1 preference 100 ip route-static 192.168.17.0 24 G0/0/1 23.1.1.2 ip route-static 192.168.17.0 24 G0/0/0 13.1.1.1 preference 100 ip route-static 192.168.18.0 24 G0/0/1 23.1.1.2 ip route-static 192.168.18.0 24 G0/0/0 13.1.1.1 preference 100 ip route-static 192.168.19.0 24 G0/0/1 23.1.1.2 ip route-static 192.168.19.0 24 G0/0/0 13.1.1.1 preference 100 ip route-static 192.168.20.0 24 G0/0/1 23.1.1.2 ip route-static 192.168.20.0 24 G0/0/0 13.1.1.1 preference 100
[AR2]的回程路由
# AR2 ip route-static 192.168.1.0 24 G0/0/0 14.1.1.1 ip route-static 192.168.1.0 24 G0/0/1 24.1.1.2 preference 100 ip route-static 192.168.2.0 24 G0/0/0 14.1.1.1 ip route-static 192.168.2.0 24 G0/0/1 24.1.1.2 preference 100 ip route-static 192.168.3.0 24 G0/0/0 14.1.1.1 ip route-static 192.168.3.0 24 G0/0/1 24.1.1.2 preference 100 ip route-static 192.168.4.0 24 G0/0/0 14.1.1.1 ip route-static 192.168.4.0 24 G0/0/1 24.1.1.2 preference 100 ip route-static 192.168.5.0 24 G0/0/0 14.1.1.1 ip route-static 192.168.5.0 24 G0/0/1 24.1.1.2 preference 100 ip route-static 192.168.6.0 24 G0/0/0 14.1.1.1 ip route-static 192.168.6.0 24 G0/0/1 24.1.1.2 preference 100 ip route-static 192.168.7.0 24 G0/0/0 14.1.1.1 ip route-static 192.168.7.0 24 G0/0/1 24.1.1.2 preference 100 ip route-static 192.168.8.0 24 G0/0/0 14.1.1.1 ip route-static 192.168.8.0 24 G0/0/1 24.1.1.2 preference 100 ip route-static 192.168.9.0 24 G0/0/0 14.1.1.1 ip route-static 192.168.9.0 24 G0/0/1 24.1.1.2 preference 100 ip route-static 192.168.10.0 24 G0/0/0 14.1.1.1 ip route-static 192.168.10.0 24 G0/0/1 24.1.1.2 preference 100 ip route-static 192.168.11.0 24 G0/0/1 24.1.1.2 ip route-static 192.168.11.0 24 G0/0/0 14.1.1.1 preference 100 ip route-static 192.168.12.0 24 G0/0/1 24.1.1.2 ip route-static 192.168.12.0 24 G0/0/0 14.1.1.1 preference 100 ip route-static 192.168.13.0 24 G0/0/1 24.1.1.2 ip route-static 192.168.13.0 24 G0/0/0 14.1.1.1 preference 100 ip route-static 192.168.14.0 24 G0/0/1 24.1.1.2 ip route-static 192.168.14.0 24 G0/0/0 14.1.1.1 preference 100 ip route-static 192.168.15.0 24 G0/0/1 24.1.1.2 ip route-static 192.168.15.0 24 G0/0/0 14.1.1.1 preference 100 ip route-static 192.168.16.0 24 G0/0/1 24.1.1.2 ip route-static 192.168.16.0 24 G0/0/0 14.1.1.1 preference 100 ip route-static 192.168.17.0 24 G0/0/1 24.1.1.2 ip route-static 192.168.17.0 24 G0/0/0 14.1.1.1 preference 100 ip route-static 192.168.18.0 24 G0/0/1 24.1.1.2 ip route-static 192.168.18.0 24 G0/0/0 14.1.1.1 preference 100 ip route-static 192.168.19.0 24 G0/0/1 24.1.1.2 ip route-static 192.168.19.0 24 G0/0/0 14.1.1.1 preference 100 ip route-static 192.168.20.0 24 G0/0/1 24.1.1.2 ip route-static 192.168.20.0 24 G0/0/0 14.1.1.1 preference 100
AR1的IP地址
# interface GigabitEthernet0/0/0 ip address 13.1.1.3 255.255.255.0 # interface GigabitEthernet0/0/1 ip address 23.1.1.3 255.255.255.0
AR2的IP地址
# interface GigabitEthernet0/0/0 ip address 14.1.1.4 255.255.255.0 # interface GigabitEthernet0/0/1 ip address 24.1.1.4 255.255.255.0 #
连通性测试
(1)由PC1pingSW1
(2)由PC1pingPC4