(超详细-配置注释)思科HSRP配置案例分享

目录

1.HSRP简介

2.建立拓扑

3.基础配置

4.HSRP配置

5.配置track,并绑定接口

6.配置路由

7.查看HSRP

8.切换测试

总结:


1.HSRP简介

HSRP (Hot Standby Router Protocol) 是一种 Cisco 专有协议,用于在多个路由器之间提供默认网关的冗余性。HSRP 使多个路由器看起来像是单个虚拟路由器,这样网络中的其他设备就可以将数据包发送到这个虚拟路由器而不用知道实际的路由器是哪个。

在 HSRP 中,一个路由器被选为 Active Router,它将处理所有接收到的数据包,并且它的 IP 地址将作为默认网关。另一个路由器则被选为 Standby Router,它将等待 Active Router 失效,并在必要时接管网络流量。其他路由器则处于 Listen 模式,它们监视 Active 和 Standby 路由器的状态,并在必要时成为 Standby 路由器。

HSRP 使用虚拟 MAC 地址来标识虚拟路由器,并使用 Hello 消息来传递路由器的状态信息。当 Active Router 失效时,Standby Router 将接管虚拟路由器,并将其 IP 地址设置为自己的地址,以确保网络流量得到正确的路由。

HSRP 可以用于提高网络的可用性和冗余性,它适用于需要高可用性和可靠性的企业网络。

2.建立拓扑


拓扑

拓扑说明:R1和R2模拟数据中心两台主备核心设备,交换机模拟接入设备,R3模拟出口设备或运营商设备。访问需求是PC6和PC7能够通过R1和R2访问到运营商设备R3,同时在R1和R2上需对转发流量进行负载分担。设备切换需求是当R1或R2发生故障时数据可以正常转发,业务不中断。

3.基础配置

R1:

R1(config)# interface ethernet 0/0
R1(config-if)# ip address 172.31.1.254 255.255.255.0

R1(config)# interface ethernet 0/1
R1(config-if)# ip address 192.168.1.254 255.255.255.0

R2:

R2(config)# interface ethernet 0/0
R2(config-if)# ip address 172.31.1.254 255.255.255.0

R2(config)# interface ethernet 0/1
R2(config-if)# ip address 192.168.1.254 255.255.255.0

R3:

R3(config)# interface ethernet 0/0
R3(config-if)# ip address 192.168.1.10 255.255.255.0

R3(config)# interface loopback1
R3(config-if)# ip address 1.1.1.1 255.255.255.255

R3(config)# interface loopback2
R3(config-if)# ip address 2.2.2.2 255.255.255.255

VPC6:

VPCS> ip 172.31.1.200 24 172.31.1.250

VPC7:

VPCS> ip 172.31.1.100 24 172.31.1.250

基础配置按照个人习惯进行配置,没有必要完全按照上面的配置。

4.HSRP配置

R1:

R1(config)# interface ethernet 0/0
R1(config-if)# standby 1 ip 172.31.1.250
R1(config-if)# standby 1 priority 120
R1(config-if)# standby 1 preempt
R1(config-if)# standby 1 authentication md5 key-string cisco

R1(config)# interface ethernet 0/0
R1(config-if)# standby 2 ip 192.168.1.250
R1(config-if)# standby 2 priority 120
R1(config-if)# standby 2 preempt
R1(config-if)# standby 2 authentication md5 key-string cisco
R1(config-if)# standby 2 track 1 decrement 50
R1(config-if)# standby 2 track 2 decrement 50

HSRP和VRRP的配置类似,工作原理也类似,区别就是 HSRP是Cisco私有协议,VRRP是国际协议。

R2:

R2(config)# interface ethernet 0/0
R2(config-if)# standby 1 ip 172.31.1.250
R2(config-if)# standby 1 preempt
R2(config-if)# standby 1 authentication md5 key-string cisco

R2(config)# interface ethernet 0/0
R2(config-if)# standby 2 ip 192.168.1.250
R2(config-if)# standby 2 preempt
R2(config-if)# standby 2 authentication md5 key-string cisco

5.配置track,并绑定接口

R1:

track 1 interface Ethernet0/0 line-protocol
track 2 interface Ethernet0/1 line-protocol
R1(config)# interface ethernet 0/0
R1(config-if)# standby 1 track 1 decrement 50
R1(config-if)# standby 1 track 2 decrement 50
R1(config-if)# standby 2 track 1 decrement 50
R1(config-if)# standby 2 track 2 decrement 50

我认为R2上不需要配置track,因为本来R1的优先级就比R2高,流量全部走的R1。当R2发生故障或者挂掉的情况下,流量路劲不会发生变化。但是当R1发生故障或者挂掉的情况下,track能快速探测到设备发生路障,不能正常转发流量,然后使得R2快速成为active并转发流量。缩短了设备故障探测时间。个人理解如有不对,请指正!

6.配置路由

R1:

ip route 0.0.0.0 0.0.0.0 192.168.1.10

R2:

ip route 0.0.0.0 0.0.0.0 192.168.1.10

R3:

ip route 0.0.0.0 0.0.0.0 172.31.1.250

7.查看HSRP

R1:

R1#show standby brief 
                     P indicates configured to preempt.
                     |
Interface   Grp  Pri P State   Active          Standby         Virtual IP
Et0/0       1    120 P Active  local           172.31.1.1      172.31.1.250
Et0/1       2    120 P Active  local           192.168.1.1     192.168.1.250

R2:

Router#show standby brief 
                     P indicates configured to preempt.
                     |
Interface   Grp  Pri P State   Active          Standby         Virtual IP
Et0/0       1    100 P Standby 172.31.1.254    local           172.31.1.250
Et0/1       2    100 P Standby 192.168.1.254   local           192.168.1.250

8.切换测试

R1发生故障:

R1(config)# interface ethernet 0/0
R1(config-if)#shutdown

VPC上追踪路由:

VPCS> trace 1.1.1.1
trace to 1.1.1.1, 8 hops max, press Ctrl+C to stop
 1   172.31.1.1   1.920 ms  3.085 ms  3.609 ms
 2   *192.168.1.10   5.647 ms (ICMP type:3, code:3, Destination port unreachable)  *

R2发生故障:

R2(config)# interface ethernet 0/0
R2(config-if)#shutdown

VPC上追踪路由:

VPCS> trace 1.1.1.1
trace to 1.1.1.1, 8 hops max, press Ctrl+C to stop
 1   172.31.1.254   1.907 ms  0.599 ms  0.468 ms
 2   *192.168.1.10   1.200 ms (ICMP type:3, code:3, Destination port unreachable)  *

总结:

HSRP和VRRP工作原理相同,配置也非常相似。配置track时可选性较多。整个设备挂掉的情况没有标出,感兴趣的可以试一试!

展开阅读全文

页面更新:2024-03-19

标签:思科   拓扑   冗余   可用性   路由   注释   路由器   流量   故障   案例   发生   地址   设备   详细

1 2 3 4 5

上滑加载更多 ↓
推荐阅读:
友情链接:
更多:

本站资料均由网友自行发布提供,仅用于学习交流。如有版权问题,请与我联系,QQ:4156828  

© CopyRight 2020-2024 All Rights Reserved. Powered By 71396.com 闽ICP备11008920号-4
闽公网安备35020302034903号

Top