Requisitos de red
Como se muestra en la figura a continuación, PC1 tiene conexión dual a R1 y R2 a través de SW1. Para garantizar que varios servicios de los usuarios no se interrumpan durante la transmisión de la red, la función de copia de seguridad activa/en espera de VRRP debe configurarse en R1 y R2.
-
En circunstancias normales, el host usa R1 como puerta de enlace predeterminada para acceder a Internet. Cuando R1 falla, R2 seguirá funcionando como puerta de enlace en lugar de R1, realizando una copia de seguridad redundante de la puerta de enlace.
-
Después de que el R1 se recupere, vuelve a ser el maestro a través de la preferencia después de un retraso de 20 segundos y realiza la transmisión de datos.
Topología
Planificación de direcciones
máquina | interfaz | IP | puerta |
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. Enrutador 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
# 设置 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
# 设置 vrrp
[R1-ospf-1]int g0/0/2
# 创建 虚拟IP
[R1-GigabitEthernet0/0/2]vrrp vrid 1 virtual-ip 192.168.10.254
# g0/0/2接口的优先级为120(越大越优先),默认是100
[R1-GigabitEthernet0/0/2]vrrp vrid 1 priority 120
# 设置接口为抢占模式,在故障恢复后延迟20s会抢占会Master的地位
[R1-GigabitEthernet0/0/2]vrrp vrid 1 preempt-mode timer delay 20
# 始终跟踪着g0/0/1端口,如果g0/0/1端口down,会将g0/0/2的优先级自动 -30
[R1-GigabitEthernet0/0/2]vrrp vrid 1 track interface g0/0/1 reduced 30
[R1-GigabitEthernet0/0/2]quit
2. Enrutador 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
# 设置 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
# 设置 vrrp
[R2-ospf-1]int g0/0/2
[R2-GigabitEthernet0/0/2]vrrp vrid 1 virtual-ip 192.168.10.254
3. Enrutador de salida 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
# 设置 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. Verifique los resultados de la configuración
Después de completar la configuración anterior, ejecute el comando display vrrp en R1 y R2 respectivamente, y podrá ver que el estado de R1 en el grupo de respaldo es Maestro, y el estado de R2 en el grupo de respaldo es Respaldo
[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. Probar la interoperabilidad de la red
# 访问出口路由器
[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. Simule la falla del enrutador R1
(1) Sé por lo anterior que la IP maestra ahora está en el enrutador 192.168.10.1 R1, y ahora intentamos desconectar la interfaz g0/0/1 del enrutador R1
[R1]int g0/0/1
[R1-GigabitEthernet0/0/1]shutdown
(2) Verifique vrrp nuevamente y descubra que Master IP: se ha desplazado al enrutador 192.168.10.2 R2
[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) Visitamos el enrutador de salida nuevamente en PC1 y encontramos que está bien
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