创建vlan
[sw1]vlan batch 1 to 2
[sw2]vlan batch 1 to 2
[sw3]vlan batch 1 to 2
[sw4]vlan batch 1 to 2
配置Eth-trunk
[sw1]int Eth-Trunk 0
[sw1-Eth-Trunk0]q
[sw1]int GigabitEthernet 0/0/3
[sw1-GigabitEthernet0/0/3]eth-trunk 0
[sw1-GigabitEthernet0/0/3]int g0/0/4
[sw1-GigabitEthernet0/0/4]eth-trunk 0
SW1与SW2相同步骤
配置trunk干道
[sw1]int Eth-Trunk 0
[sw1-Eth-Trunk0]port link-type trunk
[sw1-Eth-Trunk0]port trunk allow-pass vlan 1 to 2
[sw1]port-group group-member GigabitEthernet 0/0/1 GigabitEthernet 0/0/2
[sw1-port-group]port link-type trunk
[sw1-GigabitEthernet0/0/1]port link-type trunk
[sw1-GigabitEthernet0/0/2]port link-type trunk
[sw1-port-group]port trunk allow-pass vlan 1 to 2
[sw1-GigabitEthernet0/0/1]port trunk allow-pass vlan 1 to 2
[sw1-GigabitEthernet0/0/2]port trunk allow-pass vlan 1 to 2
SW2,3,4与SW1步骤相同
配置stp
[sw1]stp mode mstp
[sw1]stp enable
[sw1]stp region-configuration
[sw1-mst-region]region-name a
[sw1-mst-region]instance 1 vlan 1
[sw1-mst-region]instance 2 vlan 2
[sw1-mst-region]active region-configuration
[sw1]stp instance 1 root primary
[sw1]stp instance 2 root secondary
SW2与SW1相同
[sw3]stp enable
[sw3]stp region-configuration
[sw3-mst-region]region-name a
[sw3-mst-region]instance 1 vlan 1
[sw3-mst-region]instance 2 vlan 2
[sw3-mst-region]active region-configuration
SW4与SW3相同
需要注意的是region-name a是1与3,2与4为b
配置svi
[sw1]int vlan 1
[sw1-Vlanif1]ip address 172.16.2.1 24
[sw1-Vlanif1]int vlan 2
[sw1-Vlanif2]ip address 172.16.3.2 24
SW1与SW2相同
vrrp
[sw1]int vlanif 1
[sw1-Vlanif1]vrrp vrid 1 virtual-ip 172.16.2.254
[sw1-Vlanif1]vrrp vrid 1 priority 101
[sw1-Vlanif1]vrrp vrid 1 track interface GigabitEthernet 0/0/5 reduced 5
[sw1-Vlanif1]int vlanif 2
[sw1-Vlanif2]vrrp vrid 1 virtual-ip 172.16.3.254
[sw2]int vlanif 1
[sw2-Vlanif1]vrrp vrid 1 virtual-ip 172.16.2.254
[sw2-Vlanif2]vrrp vrid 1 virtual-ip 172.16.3.254
[sw2-Vlanif2]vrrp vrid 1 priority 101
[sw2-Vlanif2]vrrp vrid 1 track interface GigabitEthernet 0/0/5 reduced 5
dhcp
[sw1]dhcp enable
[sw1]ip pool a
[sw1-ip-pool-a]network 172.16.2.0 mask 24
[sw1-ip-pool-a]gateway-list 172.16.2.254
[sw1-ip-pool-a]dns-list 114.114.114.114
[sw1-ip-pool-a]q
[sw1]ip pool b
[sw1-ip-pool-b]network 172.16.3.0 mask 24
[sw1-ip-pool-b]gateway-list 172.16.3.254
[sw1-ip-pool-b]dns-list 114.114.114.114
[sw1-ip-pool-b]q
[sw1]int vlanif 1
[sw1-Vlanif1]dhcp select global
[sw1-Vlanif1]int vlanif 2
[sw1-Vlanif2]dhcp select global
[sw2]dhcp enable
[sw2]ip pool a
[sw2-ip-pool-a]network 172.16.2.0 mask 24
[sw2-ip-pool-a]gateway-list 172.16.2.254
[sw2-ip-pool-a]dns-list 114.114.114.114
[sw2-ip-pool-a]q
[sw2]ip pool b
[sw2-ip-pool-b]network 172.16.3.0 mask 24
[sw2-ip-pool-b]gateway-list 172.16.3.254
[sw2-ip-pool-b]dns-list 114.114.114.114
[sw2-ip-pool-b]q
[sw2]int vlanif 1
[sw2-Vlanif1]dhcp select global
[sw2-Vlanif1]int vlanif 2
[sw2-Vlanif2]dhcp select global
配置接入层
[sw3]int e 0/0/1
[sw3-Ethernet0/0/1]port link-type access
[sw3-Ethernet0/0/1]port default vlan 1
[sw3-Ethernet0/0/1]stp edged-port enable
[sw3-Ethernet0/0/1]int e 0/0/2
[sw3-Ethernet0/0/2]port link-type access
[sw3-Ethernet0/0/2]port default vlan 2
[sw3-Ethernet0/0/2]stp edged-port enable
SW4与SW3相同
[sw1]vlan 10
[sw1-vlan10]int vlan 10
[sw1-Vlanif10]ip address 172.16.0.1 30
[sw1-Vlanif10]int g0/0/5
[sw1-GigabitEthernet0/0/5]port link-type access
[sw1-GigabitEthernet0/0/5]port default vlan 10
[sw1]ip route-static 0.0.0.0 0 172.16.0.2
[sw2]vlan 20
[sw2-vlan20]int vlanif 20
[sw2-Vlanif20]ip add 172.16.0.6 30
[sw2-Vlanif20]int g0/0/5
[sw2-GigabitEthernet0/0/5]port link-type access
[sw2-GigabitEthernet0/0/5]port default vlan 20
[sw2]ip route-static 0.0.0.0 0 172.16.0.5
[R1]int g 0/0/1
[R1-GigabitEthernet0/0/1]ip address 172.16.0.2 30
[R1-GigabitEthernet0/0/1]int g 0/0/2
[R1-GigabitEthernet0/0/2]ip address 172.16.0.5 30
[R1-GigabitEthernet0/0/2]q
[R1]ip route-static 172.16.2.0 24 172.16.0.1
[R1]ip route-static 172.16.2.0 24 172.16.0.6
[R1]ip route-static 172.16.3.0 24 172.16.0.6
[R1]ip route-static 172.16.3.0 24 172.16.0.1
[r1-acl-basic-2000]rule permit source 172.16.0.0 0.0.255.255
[r1-GigabitEthernet0/0/0]nat outbound 2000
然后齐活儿