虛擬路由冗餘協議VRRP(Virtual Router Redundancy Protocol)是經過把幾臺路由設備聯合組成一臺虛擬的路由設備,將虛擬路由設備的IP地址做爲用戶的默認網關實現與外部網絡通訊。當網關設備發生故障時,VRRP機制可以選舉新的網關設備承擔數據流量,從而保障網絡的可靠通訊。網絡
本實驗涉及內容:ide
正常狀況下,主機以SW2爲默認網關接入Internet,當SW2故障時,SW3接替SW2做爲網關繼續進行工做,實現網關的冗餘備份。ui
當SW2故障恢復後,其延時20秒經過搶佔的方式從新成爲Master,承擔數據傳輸。3d
sw1:code
sys sysname SW1 vlan batch 200 300 400 inter vlan 200 ip add 192.168.2.2 24 //配置vlan ip地址,實現三層轉發 quit inter vlan 300 ip add 192.168.1.2 24 inter vlan 400 ip add 172.16.1.2 24 inter g0/0/1 port link-type trunk port trunk allow vlan 300 //容許vlan300經過 quit inter g0/0/2 port link-type trunk port trunk allow vlan 200 quit inter g0/0/24 port link-type trunk port trunk allow-pass vlan all quit
sw2:blog
sys sysname SW2 vlan batch 100 300 inter vlan 100 ip add 10.1.1.1 24 quit inter vlan 300 ip add 192.168.1.1 24 inter g0/0/1 port link-type trunk port trunk allow vlan 300 quit inter g0/0/3 port link-type trunk port trunk allow vlan 100 quit
SW3:接口
sys sysname SW3 vlan batch 200 100 inter vlan 200 ip add 192.168.2.1 24 quit inter vlan 100 ip add 10.1.1.2 24 inter g0/0/2 port link-type trunk port trunk allow vlan 200 quit inter g0/0/4 port link-type trunk port trunk allow vlan 100 quit
SW4:ip
sys sysname SW4 vlan 100 quit inter g0/0/3 port link-type trunk port trunk allow vlan 100 quit inter g0/0/4 port link-type trunk port trunk allow vlan 100 quit inter g0/0/5 port link-type access //配置爲access模式,鏈接電腦終端 port default vlan 100 quit
SW1:路由
ospf 1 area 0 network 192.168.1.0 0.0.0.255 //發佈直連的網絡段 network 192.168.2.0 0.0.0.255 network 172.16.1.0 0.0.0.255 quit quit
SW2:it
ospf 1 area 0 network 192.168.1.0 0.0.0.255 network 10.1.1.0 0.0.0.255 network 172.16.1.0 0.0.0.255 quit quit
SW3:
ospf 1 area 0 network 192.168.2.0 0.0.0.255 network 10.1.1.0 0.0.0.255 network 172.16.1.0 0.0.0.255 quit quit
AR1:
R1:
sys sysname R1 interface g0/0/0.400 //建立子接口 ip address 172.16.1.1 24 //配置ip地址 dot1q termination vid 400 //配置子接口dot1q封裝的單層vlan id arp broadcast enable //開啓arp 廣播 quit ospf 1 //配置ospf協議 area 0 network 172.16.1.0 0.0.0.255 return
inter VLAN 100 vrrp vrid 1 virtual-ip 10.1.1.111 //配置虛擬網關 vrrp vrid 1 priority 120 //默認優先級爲100,修改Master設備的優先級大於Backup設備 vrrp vrid 1 preempt-mode timer delay 20 //配置搶佔時間爲20s quit
inter VLAN 100 vrrp vrid 1 virtual-ip 10.1.1.111 quit
ip地址:10.1.1.100
掩碼:255.255.255.0
網關:10.1.1.111
至此,本實驗全部配置完成。
正常狀況下的鏈路轉發過程以下圖:
當主鏈路出現故障時,鏈路轉發過程以下圖:
配置vrrp負載分擔,只需將以上的步驟四作如下更改:
inter VLAN 100 vrrp vrid 1 virtual-ip 10.1.1.111 vrrp vrid 1 priority 120 vrrp vrid 1 preempt-mode timer delay 20 quit
SW3:
inter VLAN 100 vrrp vrid 1 virtual-ip 10.1.1.111 quit
inter VLAN 100 vrrp vrid 2 virtual-ip 10.1.1.111 quit
SW3:
inter VLAN 100 vrrp vrid 2 virtual-ip 10.1.1.111 vrrp vrid 2 priority 120 vrrp vrid 2 preempt-mode timer delay 20 quit