大家好,欢迎来到IT知识分享网。
背景
HSRP(Hot Standby Router Protocol,热备份路由协议)是由思科系统(Cisco Systems)开发的一种专有协议,用于增强网络的可靠性和冗余度。HSRP的主要目标是在网络中提供一个虚拟的默认网关,即使物理路由器发生故障,也能保持网络通信的连续性。
在HSRP出现之前,网络通常依赖单一的默认网关(通常是路由器)来处理所有出站流量。这意味着如果这台路由器出现故障,整个网络的连通性将受到严重影响,因为没有其他路径可以替代,其实就是防止单点故障造成业务中断。
为了解决这个问题,思科设计了HSRP,以提供一种机制,使得多个路由器可以共享一个虚拟的IP地址,从而在主路由器失败时,备用路由器能够无缝地接管其功能,保证网络服务的持续性。
工作原理
HSRP允许多台路由器(称为“HSRP路由器”)组成一个组,其中一台被指定为活跃路由器(Active Router),也就是主网关,负责转发数据包。
同时,还有一台或几台处于待机状态的路由器(Standby Routers),也就是备网关,它们时刻准备着在活跃路由器发生故障时接管其角色。
特点和优势
01 冗余
HSRP提供了高度的冗余,确保了即使在路由器硬件或软件故障的情况下,网络仍然可以正常运行
02 透明性
对于终端用户和主机来说,HSRP的切换是透明的,不会造成网络中断或重新配置
03 可扩展性
可以通过增加更多的路由器来增强网络的可靠性,而且HSRP组可以跨越不同的物理位置
实验准备
实验环境
EVE-community
设备镜像
路由器:i86bi LinuxL3-AdvEnterpriseK9-M2 157 3 May 2018.bin
交换机:i86bi linuxl2-adventerprisek9-ms.SSA.high iron .bin
PC:用路由器来模拟电脑PC,只需要关闭路由功能即可
实验目的
① 能让PC获取到地址 – DHCP
② 以DSW1和DSW2用HSRP虚拟冗余成两个VLAN的网关 — HSRP
③ R1和DSW1、DSW2通过OSPF实现内网互通 —OSPF
④ 然后实现PC 能上网,能Ping通ISP — Easy-IP(NAT)
DSW 1
DSW 2
配置
R1
Router>enable Router#conf t Router(config)#hostname R1 R1(config)#int e0/0 R1(config-if)#no shutdown R1(config-if)#ip address 192.168.100.1 255.255.255.0 R1(config-if)#exit R1(config)#int e0/1 R1(config-if)#no shutdown R1(config-if)#ip address 192.168.200.1 255.255.255.0 R1(config-if)#exit R1(config)#int e0/2 R1(config-if)#no shutdown R1(config-if)#ip address 202.101.12.2 255.255.255.0 R1(config-if)#exit OSPF R1(config)#router ospf 110 R1(config-router)#router-id 1.1.1.1 R1(config-router)#network 192.168.100.0 0.0.0.255 area 0 R1(config-router)#network 192.168.200.0 0.0.0.255 area 0 R1(config-router)#exit NAT配置 R1(config)#int e0/0 R1(config-if)#ip nat inside R1(config-if)#exit R1(config)#int e0/1 R1(config-if)#ip nat inside R1(config-if)#exit R1(config)#int e0/2 R1(config-if)#ip nat outside R1(config-if)#exit R1(config)#access-list 1 permit 192.168.0.0 0.0.255.255 R1(config)#ip nat inside source list 1 interface e0/2 overload R1(config)#ip route 0.0.0.0 0.0.0.0 202.101.12.1
DSW1
Switch>en Switch>enable Switch#conf t Switch(config)#hostname DSW1 DSW1(config)#vlan 10,20 DSW1(config-vlan)#exit 因为三层交换机是有路由功能又有交换功能的 关闭端口的交换功能,那就可以使用路由功能了 DSW1(config)#int e0/0 DSW1(config-if)#no switchport 关闭交换功能,使用路由功能 DSW1(config-if)#no shutdown DSW1(config-if)#ip address 192.168.100.2 255.255.255.0 DSW1(config-if)#exit DSW1(config)#int range e0/1-3 DSW1(config-if-range)#switchport trunk encapsulation dot1q DSW1(config-if-range)#switchport mode trunk DSW1(config-if-range)#exit HSRP配置 选举活跃路由器(主):优先级大的为活跃路由器,默认优先级100 DSW1(config)#int vlan 10 DSW1(config-if)#no shutdown 打开接口 VLANIF10接口IP为“192.168.10.252” DSW1(config-if)#ip address 192.168.10.252 255.255.255.0 HSRP组10虚拟的IP地址为“192.168.10.254” DSW1(config-if)#standby 10 ip 192.168.10.254 DSW1(config-if)#standby 10 priority 150 优先级设置为“150” DSW1(config-if)#standby 10 preempt 开启抢占功能 DSW1(config-if)#exit 这边没有指定优先级的话,默认为100 DSW1(config)#int vlan20 DSW1(config-if)#no shutdown DSW1(config-if)#standby 20 ip 192.168.20.254 DSW1(config-if)#standby 20 preempt DSW1(config-if)#exit OSPF DSW1(config)#router ospf 110 DSW1(config-router)#router-id 11.11.11.11 DSW1(config-router)#network 192.168.0.0 0.0.255.255 area 0 DSW1(config-router)#exit DHCP 这边要注意的是,DSW1和DSW2的话,都要创建多个地址池 不管是不是主网关,因为到时候活跃路由器挂掉了, 流量到时候就都走备网关了, 但这个时候又没有地址池下发地址,那就会导致业务中断 所以地址池的话,就是都要创建 DSW1(config)#ip dhcp pool vlan10 DSW1(dhcp-config)#network 192.168.10.0 255.255.255.0 DSW1(dhcp-config)#default-router 192.168.10.254 DSW1(dhcp-config)#dns-server 8.8.8.8 DSW1(dhcp-config)#exit DSW1(config)#ip dhcp pool vlan20 DSW1(dhcp-config)#network 192.168.20.0 255.255.255.0 DSW1(dhcp-config)#default-router 192.168.20.254 DSW1(dhcp-config)#dns-server 8.8.8.8 DSW1(dhcp-config)#exit 上网需要的默认路由 DSW1(config)#ip route 0.0.0.0 0.0.0.0 192.168.100.1
DSW2
Switch>enable Switch#conf t Switch(config)#hostname DSW2 DSW2(config)#vlan 10,20 DSW2(config-vlan)#exit DSW2(config)#int e0/0 DSW2(config-if)#no switchport DSW2(config-if)#no shutdown DSW2(config-if)#ip address 192.168.200.2 255.255.255.0 DSW2(config-if)#exit DSW2(config)#int range e0/1-3 DSW2(config-if-range)#switchport trunk encapsulation dot1q DSW2(config-if-range)#switchport mode trunk DSW2(config-if-range)#exit HSRP DSW2(config)#interface Vlan10 DSW2(config-if)#no shutdown DSW2(config-if)#ip address 192.168.10.253 255.255.255.0 DSW2(config-if)#standby 10 ip 192.168.10.254 DSW2(config-if)#standby 10 preempt DSW2(config-if)#exit DSW2(config)#interface Vlan20 DSW2(config-if)#no shutdown DSW2(config-if)#ip address 192.168.20.253 255.255.255.0 DSW2(config-if)#standby 20 ip 192.168.20.254 DSW2(config-if)#standby 20 priority 150 DSW2(config-if)#standby 20 preempt DSW2(config-if)#exit OSPF DSW2(config)#router ospf 110 DSW2(config-router)#router-id 12.12.12.12 DSW2(config-router)#network 192.168.0.0 0.0.255.255 area 0 DSW2(config-router)#exit DHCP DSW2(config)#ip dhcp pool vlan10 DSW2(dhcp-config)#network 192.168.10.0 255.255.255.0 DSW2(dhcp-config)#default-router 192.168.10.254 DSW2(dhcp-config)#dns-server 8.8.8.8 DSW2(dhcp-config)#exit DSW2(dhcp)#ip dhcp pool vlan20 DSW2(dhcp-config)#network 192.168.20.0 255.255.255.0 DSW2(dhcp-config)#default-router 192.168.20.254 DSW2(dhcp-config)#dns-server 8.8.8.8 DSW2(dhcp-config)#exit 上网需要的默认路由 DSW2(config)#ip route 0.0.0.0 0.0.0.0 192.168.200.1
ASW1
Switch>enable Switch#conf t Switch(config)#hostname ASW1 ASW1(config)#vlan 10 ASW1(config-vlan)#exit ASW1(config)#int e0/1 ASW1(config-if)#switchport mode access ASW1(config-if)#switchport access vlan 10 ASW1(config-if)#exit ASW1(config)#int range e0/0,e0/2 ASW1(config-if-range)#switchport trunk encapsulation dot1q ASW1(config-if-range)#switchport mode trunk ASW1(config-if-range)#exit
ASW2
Switch>enable Switch#conf t Switch(config)#hostname ASW2 ASW2(config)#vlan 20 ASW2(config-vlan)#exit ASW2(config)#int e0/1 ASW2(config-if)#switchport mode access ASW2(config-if)#switchport access vlan 20 ASW2(config-if)#exit ASW2(config)#int range e0/0,e0/2 ASW2(config-if-range)#switchport trunk encapsulation dot1q ASW2(config-if-range)#switchport mode trunk ASW2(config-if-range)#exit
PC1
Router>enable Router#conf t Router(config)#hostname PC1 关闭路由功能 PC1(config)#no ip routing 用DHCP方式获取上网地址 PC1(config)#int e0/0 PC1(config-if)#no shutdown PC1(config-if)#ip address dhcp PC1(config-if)#exit
PC2
Router>enable Router#conf t Router(config)#hostname PC2 关闭路由功能 PC2(config)#no ip routing PC2(config)#int e0/0 PC2(config-if)#no shutdown PC2(config-if)#ip address dhcp PC2(config-if)#exit
ISP
Router>en Router#conf t Router(config)#host ISP ISP(config)#int e0/0 ISP(config-if)#no shutdown ISP(config-if)#ip address 202.101.12.1 255.255.255.0 ISP(config-if)#exit
测试
查看HSRP的简要信息
查看PC接口地址
PC上网通信测试
查看PC是否按照路径走
PC1优先走DSW1:192.168.10.252
PC2优先走DSW2:192.168.20.253
免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://haidsoft.com/117159.html








