1.配置eth-trunk口
[sw1]int Eth-Trunk 0
[sw1-Eth-Trunk0]int g0/0/22
[sw1-GigabitEthernet0/0/22]eth-trunk 0
[sw1-GigabitEthernet0/0/22]int g0/0/23
[sw1-GigabitEthernet0/0/23]eth-trunk 0
[sw2]int Eth-Trunk 0
[sw2-Eth-Trunk0]int g0/0/22
[sw2-GigabitEthernet0/0/22]eth-trunk 0
[sw2-GigabitEthernet0/0/22]int g0/0/23
[sw2-GigabitEthernet0/0/23]eth-trunk 0
2.配置vlan
[sw3]int e0/0/1
[sw3-Ethernet0/0/1]port link-type access
[sw3-Ethernet0/0/1]port default vlan 1
[sw3-Ethernet0/0/1]int e0/0/2
[sw3-Ethernet0/0/2]port link-type access
[sw3-Ethernet0/0/2]port default vlan 2
[sw4]int e0/0/1
[sw4-Ethernet0/0/1]port link-type access
[sw4-Ethernet0/0/1]port default vlan 1
[sw4-Ethernet0/0/1]int e0/0/2
[sw4-Ethernet0/0/2]port link-type access
[sw4-Ethernet0/0/2]port default vlan 2
3.配置trunk
[SW1]port-group group-member GigabitEthernet 0/0/1 GigabitEthernet 0/0/2 Eth-Trunk 0
[SW1-port-group]port link-type trunk
[SW1-port-group]port trunk allow-pass vlan 2
[SW2]port-group group-member GigabitEthernet 0/0/2 GigabitEthernet 0/0/1 Eth-Trunk 0
[SW2-port-group]port link-type trunk
[SW2-port-group]port trunk allow-pass vlan 2
[SW3]port-group group-member GigabitEthernet 0/0/1 GigabitEthernet 0/0/2
[SW3-port-group]port link-type trunk
[SW3-port-group]port trunk allow-pass vlan 2
[SW4]port-group group-member GigabitEthernet 0/0/2 GigabitEthernet 0/0/1
[SW4-port-group]port link-type trunk
[SW4-port-group]port trunk allow-pass vlan 2
4.配置stp
[SW1]stp enable
[SW1]stp mode mstp
[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]stp enable
[SW2]stp mode mstp
[SW2-mst-region]region-name a
[SW2-mst-region]instance 1 vlan 1
[SW2-mst-region]instance 2 vlan 2
[SW2-mst-region]active region-configuration
[SW2]stp instance 2 root primary
[SW2]stp instance 1 root secondary
5.配置svi
[SW1]int Vlanif 1
[SW1-Vlanif 1]ip a 172.16.1.254 24
[SW1]int Vlanif 2
[SW1-Vlanif 2]ip a 172.16.2.254 24
[SW2]int Vlanif 1
[SW2-Vlanif 1]ip a 172.16.1.253 24
[SW2]int Vlanif 2
[SW2-Vlanif 2]ip a 172.16.2.253 24
6.配置vrrp
[sw1]int Vlanif 1
[sw1-Vlanif1]vrrp vrid 1 virtual-ip 172.16.1.200
[sw1-Vlanif1]vrrp vrid 1 priority 101
[sw1-Vlanif1]vrrp vrid 1 track interface g0/0/1 reduced 10
[sw1]int Vlanif 2
[sw1-Vlanif2]vrrp vrid 1 virtual-ip 172.16.1.200
[sw2]int Vlanif 1
[sw2-Vlanif1]vrrp vrid 1 virtual-ip 172.16.1.200
[sw1]int Vlanif 2
[sw2-Vlanif1]vrrp vrid 1 virtual-ip 172.16.2.200
[sw2-Vlanif1]vrrp vrid 1 priority 101
[sw2-Vlanif1]vrrp vrid 1 track interface g0/0/1 reduced 10
7.配置dhcp
[sw1]dhcp enable
[sw1]ip pool vlan1
[sw1-ip-pool-vlan1]network 172.16.1.0 mask 24
[sw1-ip-pool-vlan1]gateway-list 172.16.1.200
[sw1]ip pool vlan2
[sw1-ip-pool-vlan2]network 172.16.2.0 mask 24
[sw1-ip-pool-vlan2]gateway-list 172.16.2.200
[sw1]dhcp enable
[sw1]int vlan1
[sw1-Vlanif1]dhcp select global
[sw1]int Vlanif 2
[sw1-Vlanif2]dhcp select global
[sw2]dhcp enable
[sw2]ip pool vlan1
[sw2-ip-pool-vlan1]network 172.16.1.0 mask 24
[sw2-ip-pool-vlan1]gateway-list 172.16.1.200
[sw2]ip pool vlan2
[sw2-ip-pool-vlan2]network 172.16.2.0 mask 24
[sw2-ip-pool-vlan2]gateway-list 172.16.2.200
[sw2]dhcp enable
[sw2]int vlan1
[sw2-Vlanif1]dhcp select global
[sw2]int Vlanif 2
[sw2-Vlanif2]dhcp select global
8.配置ip
[sw1]int Vlanif 3
[sw1-Vlanif3]ip add 172.16.3.2 24
[sw1-Vlanif3]int g0/0/24
[sw1-GigabitEthernet0/0/24]port link-type access
[sw1-GigabitEthernet0/0/24]port default vlan 3
[sw1-GigabitEthernet0/0/24]stp edged-port enable
[sw2]int Vlanif 4
[sw2-Vlanif4]ip add 172.16.4.2 24
[sw2-Vlanif4]int g0/0/24
[sw2-GigabitEthernet0/0/24]port link-type access
[sw2-GigabitEthernet0/0/24]port default vlan 4
[sw2-GigabitEthernet0/0/24]stp edged-port enable
[r1]int g0/0/1
[r1-GigabitEthernet0/0/1]ip add 12.1.1.1 24
[r1-GigabitEthernet0/0/0]int g0/0/0
[r1-GigabitEthernet0/0/0]ip add 172.16.3.1 24
[r1-GigabitEthernet0/0/0]int g0/0/2
[r1-GigabitEthernet0/0/1]ip add 172.16.4.1 24
[r2]int g0/0/0
[r2-GigabitEthernet0/0/0]ip add 12.1.1.2 24
[r2-LoopBack0]ip add 2.2.2.2 24
9.配置ospf
[r1]ospf 1 router-id 10.10.10.10
[r1-ospf-1]area 0
[r1-ospf-1-area-0.0.0.0]network 172.16.3.0 0.0.0.255
[r1-ospf-1-area-0.0.0.0]network 172.16.4.0 0.0.0.255
sw1
[sw1]ospf 1 router-id 1.1.1.1
[sw1-ospf-1]area 0
[sw1-ospf-1-area-0.0.0.0]network 172.16.3.0 0.0.0.255
[sw1-ospf-1-area-0.0.0.0]network 172.16.1.0 0.0.0.255
[sw1-ospf-1-area-0.0.0.0]network 172.16.2.0 0.0.0.255
[sw2-ospf-1]silent-interface Vlanif2
[sw2-ospf-1]silent-interface GigabitEthernet0/0/1
[sw2-ospf-1]silent-interface GigabitEthernet0/0/2
sw2
[sw2]ospf 1 router-id 2.2.2.2
[sw2-ospf-1]area 0
[sw2-ospf-1-area-0.0.0.0]network 172.16.4.0 0.0.0.255
[sw2-ospf-1-area-0.0.0.0]network 172.16.1.0 0.0.0.255
[sw2-ospf-1-area-0.0.0.0]network 172.16.2.0 0.0.0.255
[sw2-ospf-1]silent-interface Vlanif2
[sw2-ospf-1]silent-interface GigabitEthernet0/0/2
[sw2-ospf-1]silent-interface GigabitEthernet0/0/1
10.连接外网
[r1]acl 2000
[r1-acl-basic-2000]rule permit source 172.16.0.0 0.0.255.255
[r1]int g0/0/0
[r1-GigabitEthernet0/0/0]nat outbound 2000
[r1]ospf 1
[r1-ospf-1]default-route-advertise
[sw1]ip route-static 172.16.0.0 16 NULL 0
[sw2]ip route-static 172.16.0.0 16 NULL 0