1.拓扑图
2.配置trunk
[sw1]interface Eth-Trunk 0
[sw1-GigabiEthernet0/0/23]eth-trunk 0
[sw1-GigabiEthernet0/0/24]eth-trunk 0
[sw2]interface Eth-Trunk 0
[sw2-GigabiEthernet0/0/23]eth-trunk 0
[sw2-GigabiEthernet0/0/24]eth-trunk 0
[sw1]port-group group-member GigabitEthernet 0/0/2 to GigabitEthernet 0/0/3 Eth-Trunk 0
[sw1-port-group]port link-type trunk
[sw1-port-group]port trunk allow-pass vlan 2 to 3
[sw2]port-group group-member GigabitEthernet 0/0/2 to GigabitEthernet 0/0/3 Eth-Trunk 0
[sw2-port-group]port link-type trunk
[sw2-port-group]port trunk allow-pass vlan 2 to 3
[sw3]port-group group-member GigabitEthernet 0/0/1 to GigabitEthernet 0/0/2 Eth-Trunk 0
[sw3-port-group]port link-type trunk
[sw3-port-group]port trunk allow-pass vlan 2
[sw3-port-group]stp edged-port enable
[sw4]port-group group-member GigabitEthernet 0/0/1 to GigabitEthernet 0/0/2 Eth-Trunk 0
[sw4-port-group]port link-type trunk
[sw4-port-group]port trunk allow-pass vlan 2
[sw4-port-group]stp edged-port enable
3.配置vlan
[sw1]vlan 2
[sw2]vlan 2
[sw3]vlan 2
[sw3-Ethernet0/0/2]port link-type access
[sw3-Ethernet0/0/2]port default vlan 2
[sw4]vlan 2
[sw4-Ethernet0/0/2]port link-type access
[sw4-Ethernet0/0/2]port default vlan 2
4.配置STP
[sw1]stp mode mstp
[sw1]stp enable
[sw1]stp region-configuration
[sw1-mst-region]regin-name a
[sw1-mst-region]instance 1 vlan 1
[sw1-mst-region]instance 2 vlan 2
[sw1-mst-region]active region-configuration
[sw2]stp mode mstp
[sw2]stp enable
[sw2]stp region-configuration
[sw2-mst-region]regin-name a
[sw2-mst-region]instance 1 vlan 1
[sw2-mst-region]instance 2 vlan 2
[sw2-mst-region]active region-configuration
sw3,sw4的配置跟sw1,sw2一样的如下:
stp mode mstp
stp enable
stp region-configuration
regin-name a
instance 1 vlan 1
instance 2 vlan 2
active region-configuration
[sw1]stp instance 1 root primary
[sw1]stp instance 2 root secondary
[sw2]stp instance 1 root secondary
[sw2]stp instance 2 root primary
5.配置svi
[sw1]interface vlan 1
[sw1-Vlanif1]ip address 172.16.1.1 25
[sw1]interface vlan 2
[sw1-Vlanif2]ip address 172.16.1.129 25
[sw2]interface vlan 1
[sw2-Vlanif1]ip address 172.16.1.2 25
[sw2]interface vlan 2
[sw2-Vlanif2]ip address 172.16.1.130 25
6.配置vrrp
[sw1]interface vlan 1
[sw1-Vlanif1]vrrp vrid 1 virtual-ip 172.16.1.126
[sw1-Vlanif1]vrrp vrid 1 priority 120
[sw1-Vlanif1]vrrp vrid 1 track interface GigabitEthernet 0/0/1 reduced 30
[sw1]interface vlan 2
[sw1-Vlanif2]vrrp vrid 1 virtual-ip 172.16.1.254
[sw2]interface vlan 1
[sw2-Vlanif1]vrrp vrid 1 virtual-ip 172.16.1.126
[sw2]interface vlan 2
[sw2-Vlanif2]vrrp vrid 1 virtual-ip 172.16.1.254
[sw2-Vlanif2]vrrp vrid 1 priority 120
[sw2-Vlanif1]vrrp vrid 1 track interface GigabitEthernet 0/0/1 reduced 30
7.配置DHCP
[sw1]dhcp enable
[sw1]ip pool g1
[sw1-ip-pool-g1]network 172.16.1.0 mask 25
[sw1-ip-pool-g1]geteway-list 172.16.1.126
[sw1-ip-pool-g1]dns-list 114.114.114.114
[sw1]ip pool v2
[sw1-ip-pool-v2]network 172.16.1.128 mask 25
[sw1-ip-pool-v2]geteway-list 172.16.1.254
[sw1-ip-pool-v2]dns-list 114.114.114.114 8.8.8.8
[sw1-Vlanif1]dhcp select global
[sw1-Vlanif2]dhcp select global
[sw2]dhcp enable
然后配置跟sw1一样:
ip pool g1
network 172.16.1.0 mask 25
geteway-list 172.16.1.126
dns-list 114.114.114.114
ip pool v2
network 172.16.1.128 mask 25
geteway-list 172.16.1.254
dns-list 114.114.114.114 8.8.8.8
dhcp select global
dhcp select global
8.最后在pc上基础配置ipv4配置为DHCP