HSRP - Hot Standby Router Protocol 热备份路由器协议
虽然HSRP本身不属于安全技术,但却可以用来给ipsec vpn的做热备提高其高可用性

一,HSRP-热备份路由器协议

1,角色:Active/Standby Active:发送hello/响应PC的arp的请求/学习虚拟IP地址(MAC)/转发数据/提供网关服务 Standby:做A的备份/发送hello/侦听224.0.0.2的消息/**响应PC的arp的请求/转发数据/提供网关服务 2,目的IP 224.0.0.2 UDP(17)源目端口皆为1985 3,虚拟MAC 0000.0c—思科 07.ac–思科分配给HSRP版本1的默认 XX–Group  Number


二.Active选举

1,priority (默认100,比大) 2,IP地址(比大) 注:Active没有抢占功能,若想通过Priority来调整主备设备,必须开启抢占功能!

interface FastEthernet0/0

ip address 12.1.1.1255.255.255.0

standby 1 ip12.1.1.254

standby 1priority 105

standby 1 preempt

三,standby选举原则

1,priority (默认100,比大) 2,IP地址(比大) 3,具有抢占功能 注:除了Active和Standby以外,其他运行HSRP的设备皆为listen状态


四,HSRP的状态

1,initial–初始化 2,learn–学习虚拟IP地址 3,listen–侦听   4,speak–选举 5,standby–必须经历的一个过程/稳定 6,active–稳定状态


五,icmp重定向

1,工作条件 做此动作的设备必须和重定向后设备在同一个子网中 2,目的 通过重新指派网关来选择去往最终目的地的最优路径 3,缺点 容易暴露真实网关设备的IP/MAC 4,在启用HSRP的接口下,自动关闭ICMP的重定向功能

Active#

\*Mar  1 01:05:51.671:ICMP:  10.1.1.2 does not contain anactive HSRP group

\*Mar  1 01:05:51.671:ICMP: redirect to 10.1.1.100 for dest 202.100.1.10 filtered

六,HSRP的feature

Active(config)#int f1/0

Active(config-if)#standby 1 ?

authentication  Authentication---认证

follow          Name of HSRP group to follow---?

ip              Enable HSRP IPv4 and set thevirtual IP address

ipv6            Enable HSRP IPv6

mac-address     Virtual MAC address--修改MAC地址

name            Redundancy name string--修改组名

preempt         Overthrow lower priority Activerouters--开启抢占

priority        Priority level---修改优先级

timers          Hello and hold timers--修改计时器

track           Priority tracking--追踪

Active(config-if)#standby 1 track 1 --number

decrement  Priority decrement--降低优先级

shutdown   Shutdown group--关闭HSRP功能

<cr>

七,HSRP实验

需求:

  • SW1 为active SW2为standby
  • 虚拟mac为 0000.0c07.ac1e
  • 开启抢占
  • SW1的优先级为110 SW2优先级为105
  • 开启MD5认证 密码为qytan

配置: 配地址  配Trunk/Access 过程略。

ESW1#sh run int vlan 10
!
interface Vlan10
ip address 192.168.1.252 255.255.255.0
standby version 1  ---HSRP版本2
standby 30 ip 192.168.1.254    ---虚拟地址
standby 30 priority 110    ----优先级
standby 30 authentication md5 key-string qytang  ---md5认证 密码为qytang
!
router eigrp 90  ---eigrp
network 0.0.0.0

ESW2#sh run int vlan 10
interface Vlan10
ip address 192.168.1.253 255.255.255.0
standby version 1
standby 30 ip 192.168.1.254
standby 30 priority 105
standby 30 preempt   ---开启抢占
standby 30 authentication md5 key-string qytang
!
router eigrp 90  ---eigrp
network 0.0.0.0

R1:
router eigrp 90
network 0.0.0.0
no auto-summary
!
interface Loopback0
ip address 100.1.1.1 255.255.255.0

验证下路由:

R1#sh ip route eigrp
100.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
D       100.0.0.0/8 is a summary, 05:55:16, Null0
10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
D       10.0.0.0/8 is a summary, 02:19:12, Null0
12.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
D       12.0.0.0/8 is a summary, 02:19:12, Null0
D    192.168.1.0/24 \[90/28416\] via 12.1.1.2, 05:07:11, FastEthernet1/0
\[90/28416\] via 10.1.1.2, 05:07:11, FastEthernet0/

R1#ping 192.168.1.254 source lo0
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.254, timeout is 2 seconds:
Packet sent with a source address of 100.1.1.1
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 20/34/60 ms

验证下HSRP:  在HSRPv1中  默认的MAC地址为:

0000.0c07.acXX 

其中XX表示HSRP组号,这里group  number为30(十进制)   正好等于1e(十六进制) R2.R3测试一下与网关(HSRP虚拟地址)的连通性:

R2:ping 192.168.1.254
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.254, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 16/33/64 ms

  测试一下到远端设备100.1.1.1  此时走Active

当去主网关的链路down掉:

ESW1(config)#int f1/0 
ESW1(config-if)#shutdown

此时已经走了备份网关。   颖奇L’Amore - 2016年1月2日

Author: Y1ng
Link: https://www.gem-love.com/2020/03/04/hsrp-hot-standby-router-protocol-热备份路由器协议/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.
【腾讯云】热门云产品首单特惠秒杀,2核2G云服务器45元/年    【腾讯云】境外1核2G服务器低至2折,半价续费券限量免费领取!