实验拓扑和地址规划如下图所示
一、创建通道将两条主线绑定起到增加带宽的作用(分别sw1和sw2上)
[sw1]int g0/0/3
[sw1-GigabitEthernet0/0/3]eth-trunk 0
[sw1-GigabitEthernet0/0/3]int g0/0/2
[sw1-GigabitEthernet0/0/2]eth-trunk 0
[sw2-GigabitEthernet0/0/2]eth-trunk 0.
[sw2-GigabitEthernet0/0/2]int g0/0/1
[sw2-GigabitEthernet0/0/1]eth-trunk 0
二、给各个交换机上配置vlan,由于交换机内部自身携带vlan1,因此这里只需要给每一台交换机配置vlan2即可,并在PC2和PC4上配置vlan接口accss
[lsw1]vlan 2
[lsw1-vlan2]
[lsw3-Ethernet0/0/4]port link-type access
[lsw3-Ethernet0/0/4]port default vlan 2
[lsw 4-Ethernet0/0/4]port link-type access
[lsw 4-Ethernet0/0/4]port default vlan 2
三、给每一个交换机之间配置trunk干道
sw1
[lsw1]port-group group-member g0/0/2 g0/0/3
[lsw1-port-group]port link-type trunk
[lsw1-GigabitEthernet0/0/2]port link-type trunk
[lsw1-GigabitEthernet0/0/3]port link-type trunk
[lsw1-port-group]port trunk allow-pass vlan 2
[lsw1-GigabitEthernet0/0/2]port trunk allow-pass vlan 2
[lsw1-GigabitEthernet0/0/3]port trunk allow-pass vlan 2
sw2
[lsw2]port-group group-member g0/0/3 g0/0/2
[lsw2-port-group]port link-type trunk
[lsw2-GigabitEthernet0/0/3]port link-type trunk
[lsw2-GigabitEthernet0/0/2]port link-type trunk
[lsw2-port-group]port trunk allow-pass vlan 2
[lsw2-GigabitEthernet0/0/3]port trunk allow-pass vlan 2
[lsw2-GigabitEthernet0/0/2]port trunk allow-pass vlan 2
sw3
[lsw3]port-group group-member e0/0/1 e0/0/2
[lsw3-port-group]port link-type trunk
[lsw3-Ethernet0/0/1]port link-type trunk
[lsw3-Ethernet0/0/2]port link-type trunk
[lsw3-port-group]port trunk allow-pass vlan 2
[lsw3-Ethernet0/0/1]port trunk allow-pass vlan 2
[lsw3-Ethernet0/0/2]port trunk allow-pass vlan 2
sw4
[lsw 4]port-group group-member e0/0/1 e0/0/2
[lsw 4-port-group]port link-type trunk
[lsw 4-Ethernet0/0/1]port link-type trunk
[lsw 4-Ethernet0/0/2]port link-type trunk
[lsw 4-port-group]port trunk allow-pass vlan 2
[lsw 4-Ethernet0/0/1]port trunk allow-pass vlan 2
[lsw 4-Ethernet0/0/2]port trunk allow-pass vlan 2
四、配置生成树协议
sw1
[lsw1]stp mode mstp
[lsw1]stp enable ——开启stp协议
[lsw1]stp region-configuration
[lsw1-mst-region]region-name a——所有设备应该在一个域内
[lsw1-mst-region]instance 1 vlan 1
[lsw1-mst-region]instance 2 vlan 2
[lsw1-mst-region]active region-configuration ——激活当前配置
sw2
[lsw2]stp mode mstp
[lsw2]stp enable
[lsw2]stp region-configuration
[lsw2-mst-region]region-name a
[lsw2-mst-region]instance 1 vlan 1
[lsw2-mst-region]instance 2 vlan 2
[lsw2-mst-region]active region-configuration
sw3
[lsw3]stp mode mstp
[lsw3]stp enable
[lsw3]stp region-configuration
[lsw3-mst-region]region-name a
[lsw3-mst-region]instance 1 vlan 1
[lsw3-mst-region]instance 2 vlan 2
[lsw3-mst-region]active region-configuration
sw4
lsw 4]stp mode mstp
[lsw 4]stp enable
[lsw 4]stp region-configuration
[lsw 4-mst-region]region-name a
[lsw 4-mst-region]instance 1 vlan 1
[lsw 4-mst-region]instance 2 vlan 2
[lsw 4-mst-region]active region-configuration
五、配置SVI接口(在sw1上和sw2上)
[lsw1]interface vlan1
[lsw1-Vlanif1]ip address 172.16.1.1 25IP地址
[lsw1]interface vlan2
[lsw1-Vlanif2]ip address 172.16.1.129 25
[lsw2]interface vlan1
[lsw2-Vlanif1]ip address 172.16.1.2 25
[lsw2]interface vlan2
[lsw2-Vlanif2]ip address 172.16.1.130 25
六、配置VRRP(在sw1和sw2上)
[lsw1-Vlanif1]vrrp vrid 1 virtual-ip 172.16.1.126
[lsw1-Vlanif1]vrrp vrid 1 priority 120
[lsw1-Vlanif1]vrrp vrid 1 track int g0/0/1 reduce 10
[lsw2-Vlanif2]vrrp vrid 1 virtual-ip 172.16.1.254
[lsw2-Vlanif1]vrrp vrid 1 virtual-ip 172.16.1.126
[lsw2-Vlanif1]vrrp vrid 1 priority 105
[lsw2-Vlanif1]vrrp vrid 1 track int g0/0/1 reduce 10
[lsw2-Vlanif2]vrrp vrid 1 virtual-ip 172.16.1.254
七、配置DHCP使主机能够自动获取IP地址
[lsw1]dhcp enable
[lsw1]ip pool v1
[lsw1-ip-pool-v1]network 172.16.1.126 mask 25
[lsw1-ip-pool-v1]gateway-list 172.16.1.126
[lsw1-Vlanif1]dhcp select global --进入接口调用地址池
[lsw1-Vlanif2]ip pool v2
Info:It’s successful to create an IP address pool.
[lsw1-ip-pool-v2]network 172.16.1.254 mask 25
[lsw1-ip-pool-v2]gateway-list 172.16.1.254
[lsw1-Vlanif1]dhcp select global --进入接口调用地址池
sw2上进行一样的操作,起到备份的效果
八、使用svi接口代替实际物理接口使得交换机具有三层交换机的功能
[lsw1]vlan 100——创建一个vlan100
[lsw1]int vlan100 ——进入vlan100虚拟接口
[lsw1-Vlanif100]ip address 172.16.0.1 30
[lsw1]interface g0/0/1——进入物理接口
[lsw1-GigabitEthernet0/0/1]port link-type access——修改接口类型为access
[lsw1-port-group-default]port default vlan 100
[lsw2]int vlan100
[lsw2-Vlanif100]ip address 172.16.0.5 30
[lsw2-Vlanif100]q
[lsw2]interface g0/0/1
[lsw2-GigabitEthernet0/0/1]port link-type access
[lsw2-GigabitEthernet0/0/1]port default vlan 100
在三层交换机和路由器上配置缺省路由,使能访问公网
[Huawei]ip route-static 0.0.0.0 0 12.0.1.2