VRRP+MSTP(多實例生成樹+雙路由冗余) 實現負載分擔
MSTP (多生成樹) 每個VLAN或者幾個VLAN擁有一顆生成樹,基於實例的生成樹。instance 1、instance 2 每個實例擁有一顆生成樹。MSTP可以實現多VLAN 的負載分擔,可以實現多廠商對接。
VRRP虛擬路由冗余協議(Virtual Router Redundancy Protocol)是由IETF提出的解決局域網中配置靜態網關出現單點失效現象的路由協議。
拓撲如下:
交換機與交換機之間的鏈路為trunk類型,放行vlan10 20
SW1配置:
[sw1]vlan batch 10 20 #創建vlan10 20 [sw1-Vlanif10]dis this # interface Vlanif10 ip address 192.168.10.1 255.255.255.0 #配置物理網關地址 vrrp vrid 1 virtual-ip 192.168.10.254 #配置vrrp組1 配置虛擬網關地址 vrrp vrid 1 priority 120 #配置優先級為120,默認100數字越大越優先,使它成為vlan10的Master vrrp vrid 1 track interface GigabitEthernet0/0/3 reduced 30 #檢測上聯端口,如果斷開優先級降低30(之后會作為backup) # [sw1-Vlanif20]dis this # interface Vlanif20 ip address 192.168.20.1 255.255.255.0 #配置vlan20的物理網關 vrrp vrid 2 virtual-ip 192.168.20.254 #配置vlan20的虛擬網關 vrrp vrid 2 preempt-mode timer delay 20 #延遲20秒后搶占 MSTP配置 [sw1]stp mode mstp #配置stp模式為mstp [sw1]stp region-configuration #進入stp配置模式 [sw1-mst-region]dis this # stp region-configuration region-name HW #配置域名為HW revision-level 1 #配置版本等級為1(可選) instance 10 vlan 10 #配置vlan10 加入實例10 instance 20 vlan 20 #配置vlan20 加入實例20 active region-configuration # [sw1]stp instance 10 root primary #配置實例10為根 [sw1]stp instance 20 root secondary #配置實例20為備份根
SW2配置:
[sw2]vlan batch 10 20 [sw2-Vlanif10]dis this # interface Vlanif10 ip address 192.168.10.2 255.255.255.0 #配置vlan10網關 vrrp vrid 1 virtual-ip 192.168.10.254 #配置vrrp組1 配置虛擬網關和SW1一樣 vrrp vrid 1 preempt-mode timer delay 20 #延遲20s后搶占 # [sw2-Vlanif20]dis this # interface Vlanif20 ip address 192.168.20.2 255.255.255.0 #配置vlan20網關 vrrp vrid 2 virtual-ip 192.168.20.254 #配置vrrp組2 配置虛擬網關和SW1一樣 vrrp vrid 2 priority 120 #配置優先級為120,使vrrp2 成為vlan20的Master vrrp vrid 2 track interface GigabitEthernet0/0/22 reduced 30 #配置上聯鏈路檢測,如果斷開優先級減去30 使它成為backup # MSTP配置 [sw2]stp mode mstp #配置stp模式為mstp [sw2]stp region-configuration #進入stp配置模式 [sw2-mst-region]dis this # stp region-configuration region-name HW #配置域名為HW revision-level 1 #配置版本等級為1(可選) instance 10 vlan 10 #配置vlan10 加入實例10 instance 20 vlan 20 #配置vlan20 加入實例20 active region-configuration # [sw2]stp instance 20 root primary #配置實例20為根 [sw2]stp instance 10 root secondary #配置實例10為備份根
SW3配置:
[sw3]vlan batch 10 20 MSTP配置 [sw3]stp mode mstp #配置stp模式為mstp [sw3]stp region-configuration #進入stp配置模式 [sw3-mst-region]dis this # stp region-configuration region-name HW #配置域名為HW revision-level 1 #配置版本等級為1(可選) instance 10 vlan 10 #配置vlan10 加入實例10 instance 20 vlan 20 #配置vlan20 加入實例20 active region-configuration #
SW4配置:
[sw4]vlan batch 10 20 MSTP配置 [sw4]stp mode mstp #配置stp模式為mstp [sw4]stp region-configuration #進入stp配置模式 [sw4-mst-region]dis this # stp region-configuration region-name HW #配置域名為HW revision-level 1 #配置版本等級為1(可選) instance 10 vlan 10 #配置vlan10 加入實例10 instance 20 vlan 20 #配置vlan20 加入實例20 active region-configuration #
測試效果:
可以看出來PC3走的是 sw1的網關
PC4走的是SW2的網關
假設SW1的上聯鏈路斷開:
SW2接管了vlan10成為了Master
<sw2>dis vrrp Vlanif10 | Virtual Router 10 State : Master #sw2變成了vlan10的Master Virtual IP : 192.168.10.254 Master IP : 192.168.10.2 PriorityRun : 100 PriorityConfig : 100 MasterPriority : 100 Preempt : YES Delay Time : 20 s TimerRun : 1 s TimerConfig : 1 s Auth type : NONE Virtual MAC : 0000-5e00-010a Check TTL : YES Config type : normal-vrrp Create time : 2021-09-07 20:41:05 UTC-08:00 Last change time : 2021-09-08 10:39:48 UTC-08:00
可以看出來PC3的數據從SW1切換到了SW2上
End