組網(wǎng)需求
如下圖所示,PC1通過SW1雙歸屬到R1和R2。為保證用戶的各種業(yè)務(wù)在網(wǎng)絡(luò)傳輸中不中斷,需在R1和R2上配置VRRP主備備份功能。
-
正常情況下,主機以R1為默認(rèn)網(wǎng)關(guān)接入Internet,當(dāng)R1故障時,R2接替R1作為網(wǎng)關(guān)繼續(xù)進行工作,實現(xiàn)網(wǎng)關(guān)的冗余備份。
-
R1故障恢復(fù)后,其延時20秒通過搶占的方式重新成為Master,承擔(dān)數(shù)據(jù)傳輸。
拓?fù)鋱D
地址規(guī)劃
機器 | 接口 | IP | 網(wǎng)關(guān) |
PC1 | 192.168.10.100 | 192.168.10.254 | |
R1 | G0/0/2 | 192.168.10.1 | |
G0/0/1 | 10.0.10.1 | ||
R2 | G0/0/2 | 192.168.10.2 | |
G0/0/1 | 10.0.20.1 | ||
R3 | G0/0/0 | 10.0.10.2 | |
G0/0/1 | 10.0.20.2 | ||
G0/0/2 | 192.168.137.10 |
1、R1?路由器
<R1>sys
[R1]un in en
[R1]sys R1
[R1]int g0/0/1
[R1-GigabitEthernet0/0/1]ip addr 10.0.10.1 24
[R1-GigabitEthernet0/0/1]int g0/0/2
[R1-GigabitEthernet0/0/2]ip addr 192.168.10.1 24
# 設(shè)置 ospf
[R1-GigabitEthernet0/0/2]ospf
[R1-ospf-1]area 0
[R1-ospf-1-area-0.0.0.0]net 192.168.10.0 0.0.0.255
[R1-ospf-1-area-0.0.0.0]net 10.0.10.0 0.0.0.255
[R1-ospf-1-area-0.0.0.0]quit
# 設(shè)置 vrrp
[R1-ospf-1]int g0/0/2
# 創(chuàng)建 虛擬IP
[R1-GigabitEthernet0/0/2]vrrp vrid 1 virtual-ip 192.168.10.254
# g0/0/2接口的優(yōu)先級為120(越大越優(yōu)先),默認(rèn)是100
[R1-GigabitEthernet0/0/2]vrrp vrid 1 priority 120
# 設(shè)置接口為搶占模式,在故障恢復(fù)后延遲20s會搶占會Master的地位
[R1-GigabitEthernet0/0/2]vrrp vrid 1 preempt-mode timer delay 20
# 始終跟蹤著g0/0/1端口,如果g0/0/1端口down,會將g0/0/2的優(yōu)先級自動 -30
[R1-GigabitEthernet0/0/2]vrrp vrid 1 track interface g0/0/1 reduced 30
[R1-GigabitEthernet0/0/2]quit
2、R2?路由器
<R2>sys
[R2]un in en
[R2]sys R2
[R2]int g0/0/1
[R2-GigabitEthernet0/0/1]ip addr 10.0.20.1 24
[R2-GigabitEthernet0/0/1]int g0/0/2
[R2-GigabitEthernet0/0/2]ip addr 192.168.10.2 24
# 設(shè)置 ospf
[R2-GigabitEthernet0/0/2]ospf
[R2-ospf-1]area 0
[R2-ospf-1-area-0.0.0.0]net 192.168.10.0 0.0.0.255
[R2-ospf-1-area-0.0.0.0]net 10.0.20.0 0.0.0.255
[R2-ospf-1-area-0.0.0.0]quit
# 設(shè)置 vrrp
[R2-ospf-1]int g0/0/2
[R2-GigabitEthernet0/0/2]vrrp vrid 1 virtual-ip 192.168.10.254
3、R3?出口路由器
<R3>sys
[R3]un in en
[R3]sys R3
[R3]int g0/0/0
[R3-GigabitEthernet0/0/0]ip addr 10.0.10.2 24
[R3-GigabitEthernet0/0/0]int g0/0/1
[R3-GigabitEthernet0/0/1]ip addr 10.0.20.2 24
[R3-GigabitEthernet0/0/1]int g0/0/2
[R3-GigabitEthernet0/0/2]ip addr 192.168.137.10 24
# 設(shè)置 ospf
[R3-GigabitEthernet0/0/2]ospf
[R3-ospf-1]area 0
[R3-ospf-1-area-0.0.0.0]net 10.0.10.0 0.0.0.255
[R3-ospf-1-area-0.0.0.0]net 10.0.20.0 0.0.0.255
[R3-ospf-1-area-0.0.0.0]net 192.168.137.0 0.0.0.255
[R3-ospf-1-area-0.0.0.0]quit
4、驗證配置結(jié)果
完成上述配置以后,在R1和R2上分別執(zhí)行display vrrp命令,可以看到R1在備份組中的狀態(tài)為Master,R2在備份組中的狀態(tài)為Backup
[R1]dis vrrp
GigabitEthernet0/0/2 | Virtual Router 1
State : Master
Virtual IP : 192.168.10.254
Master IP : 192.168.10.1
PriorityRun : 120
PriorityConfig : 120
MasterPriority : 120
Preempt : YES Delay Time : 20 s
TimerRun : 1 s
TimerConfig : 1 s
Auth type : NONE
Virtual MAC : 0000-5e00-0101
Check TTL : YES
Config type : normal-vrrp
Backup-forward : disabled
Track IF : GigabitEthernet0/0/1 Priority reduced : 30
IF state : UP
Create time : 2023-03-27 17:13:19 UTC-08:00
Last change time : 2023-03-27 17:21:26 UTC-08:00
[R2]dis vrrp
GigabitEthernet0/0/2 | Virtual Router 1
State : Backup
Virtual IP : 192.168.10.254
Master IP : 192.168.10.1
PriorityRun : 100
PriorityConfig : 100
MasterPriority : 120
Preempt : YES Delay Time : 0 s
TimerRun : 1 s
TimerConfig : 1 s
Auth type : NONE
Virtual MAC : 0000-5e00-0101
Check TTL : YES
Config type : normal-vrrp
Backup-forward : disabled
Create time : 2023-03-27 17:13:32 UTC-08:00
Last change time : 2023-03-27 17:38:02 UTC-08:00
5、?測試網(wǎng)絡(luò)互通
# 訪問出口路由器
[R1]ping 192.168.137.10
PING 192.168.137.10: 56 data bytes, press CTRL_C to break
Reply from 192.168.137.10: bytes=56 Sequence=1 ttl=255 time=20 ms
Reply from 192.168.137.10: bytes=56 Sequence=2 ttl=255 time=20 ms
Reply from 192.168.137.10: bytes=56 Sequence=3 ttl=255 time=20 ms
Reply from 192.168.137.10: bytes=56 Sequence=4 ttl=255 time=20 ms
Reply from 192.168.137.10: bytes=56 Sequence=5 ttl=255 time=20 ms
--- 192.168.137.10 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 20/20/20 ms
# 訪問 R2 路由器
[R1]ping 10.0.20.1
PING 10.0.20.1: 56 data bytes, press CTRL_C to break
Reply from 10.0.20.1: bytes=56 Sequence=1 ttl=254 time=30 ms
Reply from 10.0.20.1: bytes=56 Sequence=2 ttl=254 time=20 ms
Reply from 10.0.20.1: bytes=56 Sequence=3 ttl=254 time=30 ms
Reply from 10.0.20.1: bytes=56 Sequence=4 ttl=254 time=30 ms
Reply from 10.0.20.1: bytes=56 Sequence=5 ttl=254 time=30 ms
--- 10.0.20.1 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 20/28/30 ms
6、模擬?R1?路由器出現(xiàn)故障
(1)通過上面我知道,現(xiàn)在 Master IP 在 192.168.10.1?R1?路由器上面,現(xiàn)在我們嘗試斷開 R1?路由器的?g0/0/1?接口
[R1]int g0/0/1
[R1-GigabitEthernet0/0/1]shutdown
(2)再次查看?vrrp,發(fā)現(xiàn)Master IP:已經(jīng)漂移到 192.168.10.2?R2?路由器上面文章來源:http://www.zghlxwxcb.cn/news/detail-482504.html
[R1-GigabitEthernet0/0/1]dis vrrp
GigabitEthernet0/0/2 | Virtual Router 1
State : Backup
Virtual IP : 192.168.10.254
Master IP : 192.168.10.2
PriorityRun : 90
PriorityConfig : 120
MasterPriority : 100
Preempt : YES Delay Time : 20 s
TimerRun : 1 s
TimerConfig : 1 s
Auth type : NONE
Virtual MAC : 0000-5e00-0101
Check TTL : YES
Config type : normal-vrrp
Backup-forward : disabled
Track IF : GigabitEthernet0/0/1 Priority reduced : 30
IF state : DOWN
Create time : 2023-03-27 17:13:19 UTC-08:00
Last change time : 2023-03-27 17:54:18 UTC-08:00
(3)我們在?PC1?上面再次訪問出口路由器,發(fā)現(xiàn)是OK的文章來源地址http://www.zghlxwxcb.cn/news/detail-482504.html
PC1>ping 192.168.137.10
Ping 192.168.137.10: 32 data bytes, Press Ctrl_C to break
From 192.168.137.10: bytes=32 seq=1 ttl=254 time=47 ms
From 192.168.137.10: bytes=32 seq=2 ttl=254 time=31 ms
From 192.168.137.10: bytes=32 seq=3 ttl=254 time=32 ms
From 192.168.137.10: bytes=32 seq=4 ttl=254 time=31 ms
From 192.168.137.10: bytes=32 seq=5 ttl=254 time=32 ms
--- 192.168.137.10 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 31/34/47 ms
到了這里,關(guān)于華為路由器 VRRP主備配置的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!