创建vlan并划分接口:
[sw1]interface Eth0/0/1
[sw1-Ethernet0/0/1]port link-type access
[sw1-Ethernet0/0/1]port default vlan 1
[sw1]interface Eth0/0/2
[sw1-Ethernet0/0/2]port link-type access
[sw1-Ethernet0/0/2]port default vlan 2
[sw2]interface Eth0/0/1
[sw2-Ethernet0/0/1]port link-type access
[sw2-Ethernet0/0/1]port default vlan 1
[sw2]interface Eth0/0/2
[sw2-Ethernet0/0/2]port link-type access
[sw2-Ethernet0/0/2]port default vlan 2
ethtruck的配置
[sw1]interface Eth-Trunk 0
[sw1-Eth-Trunk0]int g0/0/2
[sw1-GigabitEthernet0/0/2]eth-trunk 0
[sw2]interface Eth-Trunk 0
[sw2-GigabitEthernet0/0/2]eth-trunk
[sw2-GigabitEthernet0/0/3]eth-trunk 0
交换机设置stp
[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]stp instance 1 root primary
[sw1]stp instance 2 root secondary
svi
[sw1-Vlanif1]ip address 172.16.1.1 24
[sw1-Vlanif2]ip address 172.16.2.1 24
vrrp
[sw1]int vlanif 1
[sw1-Vlanif1]vrrp vrid 1 virtual-ip 172.16.1.254
[sw1-Vlanif1]vrrp vrid 1 priority 101
[sw1-Vlanif1]vrrp vrid1 track int g0/0/1
[sw1-Vlanif1]int vlanif 2
[sw1-Vlanif2]vrrp vrid 2 virtual-ip 172.16.2.254
[sw1-Vlanif2]vrrp vrid2 track int g0/0/1
[sw2]int vlanif 1
[sw2-Vlanif1]vrrp vrid 1 virtual-ip 172.16.1.254
[sw2-Vlanif1]vrrp vrid 1 track int g0/0/1
[sw2-Vlanif1]int vlanif 2
[sw2-Vlanif2]vrrp vrid2 virtual-ip 172.16.2.254
[sw2-Vlanif2]vrrp vrid 2 priority 101
[sw2-Vlanif2]vrrp vrid 2track int g0/0/1
dhcp
[sw1]dhcp enable
[sw1]ip pool v1
[sw1-ip-pool-v1]network 172.16.1.0 mask 24
[sw1-ip-pool-v1]gateway-list 172.16.1.254
[sw1-ip-pool-v1]dns-list 114.114.114.114
[sw1-ip-pool-v2]network 172.16.2.0 mask 24
[sw1-ip-pool-v2]gateway-list 172.16.2.254
[sw1-ip-pool-v2]dns-list 114.114.114.11
[sw1]int vlanif 1
[sw1-Vlanif1]dhcp select global
[sw1-Vlanif1]int vlanif 2
[sw1-Vlanif2]dhcp select global
路由器配置
[sw1]vlan 10
[sw1-vlan10]int vlan 10
[sw1-Vlanif10]ip address 172.16.10.1 24
[sw1-Vlanif10]int g0/0/1
[sw1-GigabitEthernet0/0/1]port link-type access
[sw1-GigabitEthernet0/0/1]port default vlan 10
[sw1]ip route-static 0.0.0.0 0 172.16.10.2
[sw2]vlan 20
[sw2-vlan20]int vlan 20
[sw2-Vlanif20]ip address 172.16.20.1 24
[sw2-Vlanif20]int g0/0/1
[sw2-GigabitEthernet0/0/1]port link-type access
[sw2-GigabitEthernet0/0/1]port default vlan 20
[sw2-GigabitEthernet0/0/1]ip route-static 0.0.0.0 0 172.16.20.2
[R1]int g0/0/0
[R1-GigabitEthernet0/0/0]ip address 172.16.10.2 24
[R1-GigabitEthernet0/0/0]int g0/0/1
[R1-GigabitEthernet0/0/1]ip address 172.16.20.2 24
[R1-GigabitEthernet0/0/1]qu
[R1]ip route-static 172.16.2.0 24 172.16.20.1
[R1]ip route-static 172.16.2.0 24 172.16.10.1
[R1]ip route-static 172.16.3.0 24 172.16.10.1
[R1]ip route-static 172.16.3.0 24 172.16.20.1
[R1]int g0/0/2
[R1-GigabitEthernet0/0/2]ip address 12.1.1.1 24
[Huawei]sysname ISP
[ISP]int g0/0/0
[ISP-acl-basic-2000]int g0/0/2
[ISP-GigabitEthernet0/0/2]nat outbound 2000
[ISP-GigabitEthernet0/0/2]qu
[ISP]ip route-static 0.0.0.0 0 12.1.1.2