作业十二:VRRP的原理和配置
实验环境
实验思路
- 规划并配置IP
- 配置ospf
- 配置主备形式
- 配置互为主备形式
- 配置监控上行接口
实验步骤
规划并配置IP
PC1:
PC2:
R1:
[R1]int g0/0/0
[R1-GigabitEthernet0/0/0]ip add 10.1.12.1 24
[R1-GigabitEthernet0/0/0]
[R1-GigabitEthernet0/0/0]int g0/0/1
[R1-GigabitEthernet0/0/1]ip add 10.1.13.1 24
[R1-GigabitEthernet0/0/1]int lo 0
[R1-LoopBack0]ip add 1.1.1.1 32
R2:
[R2]int g0/0/0
[R2-GigabitEthernet0/0/0]ip add 10.1.12.2 24
[R2-GigabitEthernet0/0/0]int g0/0/1
[R2-GigabitEthernet0/0/1]ip add 192.168.1.4 24
[R2]int lo 0
[R2-LoopBack0]ip add 2.2.2.2 32
R3:
[R3]int g0/0/1
[R3-GigabitEthernet0/0/1]ip add 10.1.13.3 24
[R3-GigabitEthernet0/0/1]int g0/0/0
[R3-GigabitEthernet0/0/0]ip add 192.168.1.3 24
[R3]int lo 0
[R3-LoopBack0]ip add 3.3.3.3 32
配置ospf
R1:
[R1]ospf router-id 1.1.1.1
[R1-ospf-1]area 1
[R1-ospf-1-area-0.0.0.1]network 1.1.1.1 0.0.0.0
[R1-ospf-1-area-0.0.0.1]network 10.1.12.1 0.0.0.0
[R1-ospf-1-area-0.0.0.1]network 10.1.13.1 0.0.0.0
R2:
[R2]ospf router-id 2.2.2.2
[R2-ospf-1]area 1
[R2-ospf-1-area-0.0.0.1]network 2.2.2.2 0.0.0.0
[R2-ospf-1-area-0.0.0.1]network 192.168.1.4 0.0.0.0
[R2-ospf-1-area-0.0.0.1]network 10.1.12.2 0.0.0.0
R3:
[R3]ospf router-id 3.3.3.3
[R3-ospf-1]area 1
[R3-ospf-1-area-0.0.0.1]network 3.3.3.3 0.0.0.0
[R3-ospf-1-area-0.0.0.1]network 192.168.1.3 0.0.0.0
[R3-ospf-1-area-0.0.0.1]network 10.1.13.3 0.0.0.0
配置主备形式
配置ARRP:
R2:
[R2]int g0/0/1
[R2-GigabitEthernet0/0/1]vrrp vrid 1 virtual-ip 192.168.1.254
R3:
[R3]int g0/0/0
[R3-GigabitEthernet0/0/0]vrrp vrid 1 virtual-ip 192.168.1.254
PC1配置网关:
PC2配置网关:
R2查看VRRP表:
[R2]dis vrrp
GigabitEthernet0/0/1 | Virtual Router 1
State : Master
Virtual IP : 192.168.1.254
Master IP : 192.168.1.4
PriorityRun : 100
PriorityConfig : 100
MasterPriority : 100
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 : 2021-03-23 16:17:43 UTC-08:00
Last change time : 2021-03-23 16:17:47 UTC-08:00
R3查看VRRP表:
[R3-GigabitEthernet0/0/0]dis vrrp
GigabitEthernet0/0/0 | Virtual Router 1
State : Backup
Virtual IP : 192.168.1.254
Master IP : 192.168.1.4
PriorityRun : 100
PriorityConfig : 100
MasterPriority : 100
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 : 2021-03-23 16:18:52 UTC-08:00
Last change time : 2021-03-23 16:18:52 UTC-08:00
PC1 ping 1.1.1.1
PC>ping 1.1.1.1
Ping 1.1.1.1: 32 data bytes, Press Ctrl_C to break
Request timeout!
From 1.1.1.1: bytes=32 seq=2 ttl=254 time=47 ms
From 1.1.1.1: bytes=32 seq=3 ttl=254 time=31 ms
From 1.1.1.1: bytes=32 seq=4 ttl=254 time=47 ms
From 1.1.1.1: bytes=32 seq=5 ttl=254 time=62 ms
--- 1.1.1.1 ping statistics ---
5 packet(s) transmitted
4 packet(s) received
20.00% packet loss
round-trip min/avg/max = 0/46/62 ms
修改R3的优先级
[R3]int g0/0/0
[R3-GigabitEthernet0/0/0]vrrp vrid 1 priority 130
R2查看VRRP表
[R2]dis vrrp
GigabitEthernet0/0/1 | Virtual Router 1
State : Backup
Virtual IP : 192.168.1.254
Master IP : 192.168.1.3
PriorityRun : 100
PriorityConfig : 100
MasterPriority : 130
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 : 2021-03-23 16:17:43 UTC-08:00
Last change time : 2021-03-23 16:34:02 UTC-08:00
R3查看VRRP表
[R3]dis vrrp
GigabitEthernet0/0/0 | Virtual Router 1
State : Master
Virtual IP : 192.168.1.254
Master IP : 192.168.1.3
PriorityRun : 130
PriorityConfig : 130
MasterPriority : 130
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 : 2021-03-23 16:18:52 UTC-08:00
Last change time : 2021-03-23 16:34:01 UTC-08:00
PC1 ping 1.1.1.1时对R3的g0/0/1抓包
配置互为主备形式
配置ARRP:
R2:
[R2]int g0/0/1
[R2-GigabitEthernet0/0/1]vrrp vrid 2 virtual-ip 192.168.1.253
[R2-GigabitEthernet0/0/1]vrrp vrid 2 priority 130
R3:
[R3]int g0/0/0
[R3-GigabitEthernet0/0/0]vrrp vrid 2 virtual-ip 192.168.1.253
修改PC2的网关:
R2查看VRRP表:
[R2-GigabitEthernet0/0/1]dis vrrp
GigabitEthernet0/0/1 | Virtual Router 1
State : Backup
Virtual IP : 192.168.1.254
Master IP : 192.168.1.3
PriorityRun : 100
PriorityConfig : 100
MasterPriority : 130
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 : 2021-03-23 16:17:43 UTC-08:00
Last change time : 2021-03-23 16:34:02 UTC-08:00
GigabitEthernet0/0/1 | Virtual Router 2
State : Master
Virtual IP : 192.168.1.253
Master IP : 192.168.1.4
PriorityRun : 130
PriorityConfig : 130
MasterPriority : 130
Preempt : YES Delay Time : 0 s
TimerRun : 1 s
TimerConfig : 1 s
Auth type : NONE
Virtual MAC : 0000-5e00-0102
Check TTL : YES
Config type : normal-vrrp
Backup-forward : disabled
Create time : 2021-03-23 16:48:04 UTC-08:00
Last change time : 2021-03-23 16:48:08 UTC-08:00
R3查看VRRP表:
[R3]dis vrrp
GigabitEthernet0/0/0 | Virtual Router 1
State : Master
Virtual IP : 192.168.1.254
Master IP : 192.168.1.3
PriorityRun : 130
PriorityConfig : 130
MasterPriority : 130
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 : 2021-03-23 16:18:52 UTC-08:00
Last change time : 2021-03-23 16:34:01 UTC-08:00
GigabitEthernet0/0/0 | Virtual Router 2
State : Backup
Virtual IP : 192.168.1.253
Master IP : 192.168.1.4
PriorityRun : 100
PriorityConfig : 100
MasterPriority : 130
Preempt : YES Delay Time : 0 s
TimerRun : 1 s
TimerConfig : 1 s
Auth type : NONE
Virtual MAC : 0000-5e00-0102
Check TTL : YES
Config type : normal-vrrp
Backup-forward : disabled
Create time : 2021-03-23 16:49:26 UTC-08:00
Last change time : 2021-03-23 16:49:26 UTC-08:00
PC1 ping 1.1.1.1 时对R3的g0/0/1抓包:
PC2 ping 1.1.1.1 时对R2的g0/0/0抓包:
配置监控上行接口
关闭R3上行接口g0/0/1:
[R3]int g0/0/1
[R3-GigabitEthernet0/0/1]shutdown
配置R3静默接口g0/0/0:
[R3]ospf router-id 3.3.3.3
[R3-ospf-1]silent-interface g0/0/0
配置ARRP:
[R3-ospf-1]q
[R3]int g0/0/0
[R3-GigabitEthernet0/0/0]vrrp vrid 1 track int g0/0/1 reduced 40
R3上查看VRRP表:
[R3]dis vrrp
GigabitEthernet0/0/0 | Virtual Router 1
State : Backup
Virtual IP : 192.168.1.254
Master IP : 192.168.1.4
PriorityRun : 90
PriorityConfig : 130
MasterPriority : 100
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
Track IF : GigabitEthernet0/0/1 Priority reduced : 40
IF state : DOWN
Create time : 2021-03-23 16:18:52 UTC-08:00
Last change time : 2021-03-23 19:36:12 UTC-08:00
GigabitEthernet0/0/0 | Virtual Router 2
State : Backup
Virtual IP : 192.168.1.253
Master IP : 192.168.1.4
PriorityRun : 100
PriorityConfig : 100
MasterPriority : 130
Preempt : YES Delay Time : 0 s
TimerRun : 1 s
TimerConfig : 1 s
Auth type : NONE
Virtual MAC : 0000-5e00-0102
Check TTL : YES
Config type : normal-vrrp
Backup-forward : disabled
Create time : 2021-03-23 16:49:26 UTC-08:00
Last change time : 2021-03-23 16:49:26 UTC-08:00
PC1 ping 1.1.1.1 时对R2的g0/0/0抓包:
实验总结
通过本次实验,我学会了ARRP的原理和配置。VRRP的作用是让多个网关协同工作又不冲突,防止单点故障。具体实现是将多个路由器虚拟成一个虚拟路由器,配置虚拟路由器的IP为默认网关,实现网络备份。虚拟路由器的组成路由首先根据优先级选举出Master,其余路由为Backup。Master会周期性的发送VRRP通告报文来通知Backup自己是正常状态,若Master故障,Backup接收不到VRRP通告报文,在抢占时间过后抢占Master。抢占时间=3*ARRP周期发报文时间+(256-自身优先级)/256秒。当故障的路由修好后收到ARRP通告报文,由优先级可知需要抢占,需要设置抢占延迟,较ospf收敛时间长。同时也可以设置多个虚拟路由器,减少闲置的备份路由,进行流量分担。若上行口故障,可以利用ARRP的联动功能监视上行口或者链路故障,主动进行主备切换。