因为eNSP模拟器里使用的SW3700这台设备不支持三层交换机的功能,所以我们需要利用SVI(switch virtual interface)来实现汇聚层与核心层的通信;
[SW1]vlan 99
[SW1-vlan99]q
[SW1]interface Vlanif 99
[SW1-Vlanif99]ip address 192.168.1.2 24
[SW1-Vlanif99]q
[SW1]interface Ethernet0/0/1
[SW1-Ethernet0/0/1]port link-type access
[SW1-Ethernet0/0/1]port default vlan 99
[SW2]vlan 98
[SW2-vlan98]q
[SW2]interface Vlanif 98
[SW2-Vlanif98]ip address 192.168.2.2 24
[SW2-Vlanif98]q
[SW2]interface Ethernet0/0/1
[SW2-Ethernet0/0/1]port link-type access
[SW2-Ethernet0/0/1]port default vlan 98
[R1]rip 1
[R1-rip-1]version 2
[R1-rip-1]network 192.168.1.0
[R1-rip-1]network 192.168.2.0
[SW1]rip 1
[SW1-rip-1]version 2
[SW1-rip-1]network 192.168.1.0
[SW2]rip 1
[SW2-rip-1]version 2
[SW2-rip-1]network 192.168.2.0
[SW1]interface Eth-Trunk 0
[SW1-Eth-Trunk0]q
[SW1]interface Ethernet0/0/2
[SW1-Ethernet0/0/2]eth-trunk 0
[SW1-Ethernet0/0/2]interface Ethernet0/0/3
[SW1-Ethernet0/0/3]eth-trunk 0
[SW1-Ethernet0/0/3]q
[SW1]interface Eth-Trunk 0
[SW1-Eth-Trunk0]port link-type trunk
[SW1-Eth-Trunk0]port trunk allow-pass vlan all
SW2同样的配置!
[SW3]vlan 2
[SW3-vlan2]q
[SW3]interface Ethernet0/0/4
[SW3-Ethernet0/0/4]port link-type access
[SW3-Ethernet0/0/4]port default vlan 2
[SW4]vlan 2
[SW4]interface Ethernet0/0/4
[SW4-Ethernet0/0/4]port link-type access
[SW4-Ethernet0/0/4]port default vlan 2
[SW1]interface Ethernet0/0/4
[SW1-Ethernet0/0/4]port link-type trunk
[SW1-Ethernet0/0/4]port trunk allow-pass vlan all
[SW1-Ethernet0/0/4]interface Ethernet0/0/5
[SW1-Ethernet0/0/5]port link-type trunk
[SW1-Ethernet0/0/5]port trunk allow-pass vlan all
其他三台switch也是同样!
[SW1]vlan 2
[SW1-vlan2]q
[SW1]stp enable
[SW1]stp mode mstp
[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
其余四台switch同样的配置!
配置完成后,我们需要在SW1和SW2中定义谁是主根,谁是副根?
我们让SW1成为vlan1的主根,SW2成为vlan1的副根;SW2成为vlan2的主根,SW1成为vlan2的副根;
[SW1]stp instance 1 root primary
[SW1]stp instance 2 root secondary
在SW2中相反即可:
[SW2]stp instance 1 root secondary
[SW2]stp instance 2 root primary
STP协议已经全部配置完成!
我们首先拿vlan1来做一个演示:
[SW1]interface Vlanif 1
[SW1-Vlanif1]ip address 172.16.1.1 24
[SW2]interface Vlanif 2
[SW2-Vlanif2]ip address 172.16.1.2 24
现在相当于是我们给vlan1设置了两个网关!
然后我们进入VRRP的配置:
如果是真实的物理接口我们需要进入到真实的物理接口里进行配置,因为模拟器的原因,我们只能进入到SVI虚拟接口里配置!
[SW1]interface Vlanif 1
[SW1-Vlanif1]ip address 172.16.1.1 24
[SW1-Vlanif1]vrrp vrid 1 virtual-ip 172.16.1.250
[SW1-Vlanif1]vrrp vrid 1 priority 120
[SW1-Vlanif1]vrrp vrid 1 track interface Vlanif 99 reduced 30
[SW2]interface Vlanif 1
[SW2-Vlanif1]vrrp vrid 1 virtual-ip 172.16.1.250
配置DHCP:
[SW1]ip pool xixi
[SW1-ip-pool-xixi]network 172.16.1.0 mask 24
[SW1-ip-pool-xixi]gateway-list 172.16.1.250
[SW1-ip-pool-xixi]dns-list 8.8.8.8
[SW1-ip-pool-xixi]q
[SW1]dhcp enable
[SW1]interface Vlanif 1
[SW1-Vlanif1]dhcp select global
[SW2]ip pool xixi
[SW2-ip-pool-xixi]network 172.16.1.0 mask 24
[SW2-ip-pool-xixi]gateway-list 172.16.1.250
[SW2-ip-pool-xixi]dns-list 8.8.8.8
[SW2-ip-pool-xixi]q
[SW2]dhcp enable
[SW2]interface Vlanif 1
[SW2-Vlanif1]dhcp select global
只需在SW1和SW2中宣告用户的网段即可:
[SW1]rip 1
[SW1-rip-1]version 2
[SW1-rip-1]network 172.16.0.0
[SW2]rip 1
[SW2-rip-1]version 2
[SW2-rip-1]network 172.16.0.0
测试:
我们在PC1上ping核心层:
现在我们来测试一下VRRP是否生效:
让PC1一直ping核心层,然后我们将主根down掉,看是否起到一个备份的作用?
长ping命令:
ping 192.168.1.1 -t
经检验:中途丢包之后又重新正常连通;
此实验中vrrp网关冗余我们只做了vlan1的,当然也应该将vlan2也做同样的配置即可!
如果需要和ISP通信,只需配置相应的接口IP地址并且做NAT即ss