当前位置: 移动技术网 > 网络运营>网络>协议 > hsrp vrrp在企业网中的应用

hsrp vrrp在企业网中的应用

2018年03月29日  | 移动技术网网络运营  | 我要评论

Vrrp简介

虚拟冗余协议(VRRP)是一种选择协议,它可以把一个虚拟路由器的责任动态分配到局域网上的 VRRP 路由器中的一台。控制虚拟路由器 IP 地址的 VRRP 路由器称为主路由器,它负责转发数据包到这些虚拟 IP 地址。一旦主路由器不可用,这种选择过程就提供了动态的故障转移机制,这就允许虚拟路由器的 IP 地址可以作为终端主机的默认第一跳路由器。使用 VRRP 的好处是有更高的默认路径的可用性而无需在每个终端主机上配置动态路由或路由发现协议。 VRRP 包封装在 IP 包中发送。
  www.2cto.com  

Vrrp工作原理

vrrp只定义了一种报文——vrrp报文,这是一种组播报文,由主三层定时发出来通告他的存在。使用这些报文可以检测虚拟三层交换机各种参数,还可以用于主三层交换机的选举。

VRRP中定义了三种状态模型,初始状态Initialize,活动状态Master和备份状态Backup,其中只有活动状态的交换机可以为到虚拟IP地址的的转发请求提供服务。

vrrp报文是封装在IP报文上的,支持各种上层协议,同时VRRP还支持将真实接IP地址设置为虚拟IP地址。

虚拟交换机根据配置的优先级的大小选择主交换机,优先级最大的作为主交换机,状态为Master,若优先级相同(如果交换机没有配置优先级,就采用默认值100),则比较接口的主IP地址,主IP地址大的就成为主交换机,由它提供实际的路由服务。其他交换机作为备份交换机,随时监测主交换机的状态。
  www.2cto.com  

Vrrp主要配置命令

设定虚拟 IP 地址是否可以使用ping 命令ping 通

vrrp ping-enabale

添加备份组接口的虚拟ip地址

vrrp vrid virtual_router_id virtual-ip ip-address

设置备份组的优先级

vrrp vrid virtual_router_id priority priority

设置备份组的抢占方式和延迟时间

vrrp vrid virtual_router_id preempt-mode [ timer-delay seconds ]

设置备份组的认证方式和认证字

vrrp authentication-mode simple [ key ]

设置备份组的定时器

vrrp vrid virtual_router_id timer-advertise seconds

设置监视指定接口

vrrp vrid virtual_router_id track interface_type interface_number [ reduced priority ]

VRRP 的显示和调试

显示 VRRP 的状态信息display vrrp

打开VRRP 调试信息开关debugging vrrp { packet | state }

案例一(vrrp)

设备:交换机Quidway S3526 Quidway 2000 series各1台

路由器Quidway 2600 2台

拓扑图:

路由器R1配置:

路由器R2配置

交换机SW1配置

interface Ethernet0/23

port link-type trunk

port trunk permit vlan all

#

interface Ethernet0/24

port link-type trunk

port trunk permit vlan all

交换机SW2配置

interface Ethernet1/0/23

port link-type trunk

port trunk permit vlan all

#

interface Ethernet1/0/24

port link-type trunk

port trunk permit vlan all

#

测试:

案例二(hsrp)

HSRP简介

HSRP:热备份路由器协议(HSRP:Hot Standby Router Protocol),是cisco平台一种特有的技术,是cisco的私有协议。

热备份路由器协议(HSRP)的设计目标是支持特定情况下 IP 流量失败转移不会引起混乱、并允许主机使用单路由器,以及即使在实际第一跳路由器使用失败的情形下仍能维护路由器间的连通性。换句话说,当源主机不能动态知道第一跳路由器的 IP 地址时,HSRP 协议能够保护第一跳路由器不出故障。
  www.2cto.com  

工作原理

负责转发数据包的路由器称之为活动路由器(Active Router)。一旦主动路由器出现故障,HSRP 将激活备份路由器(Standby Routers)取代主动路由器。HSRP 协议提供了一种决定使用主动路由器还是备份路由器的机制,并指定一个虚拟的 IP 地址作为网络的缺省网关地址。如果主动路由器出现故障,备份路由器(Standby Routers)承接主动路由器的所有任务,并且不会导致主机连通中断现象。

HSRP 运行在 UDP 上,采用端口号1985。路由器转发协议数据包的源地址使用的是实际 IP 地址,而并非虚拟地址,正是基于这一点,HSRP 路由器间能相互识别.

HSRP与VRRP和差别

1.在功能上,VRRP和HSRP非常相似,但是就安全而言,VRRP对HSRP的一个主要优势:它允许参与VRRP组的设备间建立认证机制.并且,不像HSRP那样要求虚拟路由器不能是其中一个路由器的ip地址,但是VRRP允许这种情况发生(如果”拥有”虚拟路由器地址的路由器被建立并且正在运行,那么应该总是由这个虚拟路由器管理—等价于HSRP中的活动路由器),但是为了确保万一失效发生的时候终端主机不必重新学习MAC地址,它指定使用的MAC地址00-00-5e-00-01-VRID,这里的VRID是虚拟路由器的ID(等价于一个HSRP的组标识符).

2.另外一个不同是VRRP不使用HSRP中的政变或者一个等价消息,VRRP的状态机比HSRP的要简单,HSRP有6个状态(初始(Initial)状态,学习(Learn)状态,监听(Listen)状态,对话(Speak)状态,备份(Standby)状态,活动(Active)状态)和8个事件, VRRP只有3个状态(初始状态(Initialize)、主状态(Master)、备份状态(Backup))和5个事件.  www.2cto.com  

3. HSRP有三种报文,而且有三种状态可以发送报文 呼叫(Hello)报文 告辞(Resign)报文 突变(Coup)报文

VRRP有一种报文

VRRP广播报文:由主路由器定时发出来通告它的存在,使用这些报文可以检测虚拟路由器各种参数,还可以用于主路由器的选举。

4. HSRP将报文承载在UDP报文上,而VRRP承载在IP报文上(HSRP 使用UDP 1985端口,向组播地址224.0.0.2 发送hello消息。)

5.VRRP的安全:VRRP协议包括三种主要的认证方式:无认证,简单的明文密码和使用 MD5 HMAC ip认证的强认证.

步骤

R1的配置

R1#show standby all

Ethernet0/0.10 - Group 10

State is Active

2 state changes, last state change 00:01:21

Virtual IP address is 192.168.10.254

Active virtual MAC address is 0000.0c07.ac0a

Local virtual MAC address is 0000.0c07.ac0a (v1 default)

Hello time 3 sec, hold time 10 sec

Next hello sent in 2.204 secs

Preemption enabled, delay min 5 secs

Active router is local

Standby router is unknown

Priority 120 (configured 120)

IP redundancy name is "hsrp-Et0/0.10-10" (default)

Ethernet0/0.20 - Group 20

State is Active

2 state changes, last state change 00:00:19

Virtual IP address is 192.168.20.254

Active virtual MAC address is 0000.0c07.ac14

Local virtual MAC address is 0000.0c07.ac14 (v1 default)

Hello time 3 sec, hold time 10 sec

Next hello sent in 1.836 secs

Preemption enabled, delay min 5 secs

Active router is local

Ethernet0/0 (not full duplex), with sw1 FastEthernet0/0 (full duplex).

Standby router is unknown

Priority 80 (configured 80)

IP redundancy name is "hsrp-Et0/0.20-20" (default)

interface Ethernet0/0

no ip address

half-duplex

!

interface Ethernet0/0.10

encapsulation dot1Q 10

ip address 192.168.10.1 255.255.255.0 //子接口ip地址

standby 10 ip 192.168.10.254 //虚拟ip地址

standby 10 priority 120 //优先级

standby 10 preempt delay minimum 5 //设置备份组的抢占方式和延迟时间

!

interface Ethernet0/0.20

encapsulation dot1Q 20

ip address 192.168.20.1 255.255.255.0

standby 20 ip 192.168.20.254

standby 20 priority 80

standby 20 preempt delay minimum 5

R2的配置

R2#show standby all

Ethernet0/0.10 - Group 10

State is Active

2 state changes, last state change 00:01:40

Virtual IP address is 192.168.10.254

Active virtual MAC address is 0000.0c07.ac0a

Local virtual MAC address is 0000.0c07.ac0a (v1 default)

Hello time 3 sec, hold time 10 sec

Next hello sent in 1.200 secs

Preemption enabled, delay min 5 secs

Active router is local

Standby router is unknown

Priority 80 (configured 80)

IP redundancy name is "hsrp-Et0/0.10-10" (default)

Ethernet0/0.20 - Group 20

State is Active

2 state changes, last state change 00:00:12

Virtual IP address is 192.168.20.254

Active virtual MAC address is 0000.0c07.ac14

Local virtual MAC address is 0000.0c07.ac14 (v1 default)

Hello time 3 sec, hold time 10 sec

Next hello sent in 2.388 secs

Preemption enabled, delay min 5 secs

Active router is local

Standby router is unknown

Priority 120 (configured 120)

IP redundancy name is "hsrp-Et0/0.20-20" (default)

Sw1的配置

sw1#show int f0/0 switchport

Name: Fa0/0

Switchport: Enabled

Administrative Mode: trunk

Operational Mode: trunk

Administrative Trunking Encapsulation: dot1q

Operational Trunking Encapsulation: dot1q

Negotiation of Trunking: Disabled

Access Mode VLAN: 0 ((Inactive))

Trunking Native Mode VLAN: 1 (default)

Trunking VLANs Enabled: ALL

Trunking VLANs Active: 1,10,20

Priority for untagged frames: 0

Override vlan tag priority: FALSE

Voice VLAN: none

Appliance trust: none

sw1#show int f0/1 switchport

Name: Fa0/1

Switchport: Enabled

Administrative Mode: trunk

Operational Mode: trunk

Administrative Trunking Encapsulation: dot1q

Operational Trunking Encapsulation: dot1q

Negotiation of Trunking: Disabled

Access Mode VLAN: 0 ((Inactive))

Trunking Native Mode VLAN: 1 (default)

Trunking VLANs Enabled: ALL

Trunking VLANs Active: 1,10,20

Priority for untagged frames: 0

Override vlan tag priority: FALSE

Voice VLAN: none

Appliance trust: none

sw1#

interface FastEthernet0/0

switchport mode trunk

!

interface FastEthernet0/1

switchport mode trunk

Sw2的配置

sw2#show int f0/0 switchport

Name: Fa0/0

Switchport: Enabled

Administrative Mode: trunk

Operational Mode: trunk

Administrative Trunking Encapsulation: dot1q

Operational Trunking Encapsulation: dot1q

Negotiation of Trunking: Disabled

Access Mode VLAN: 0 ((Inactive))

Trunking Native Mode VLAN: 1 (default)

Trunking VLANs Enabled: ALL

Trunking VLANs Active: 1,10,20

Priority for untagged frames: 0

Override vlan tag priority: FALSE

Voice VLAN: none

Appliance trust: none

sw2#show int f0/1 switchport

Name: Fa0/1

Switchport: Enabled

Administrative Mode: trunk

Operational Mode: trunk

Administrative Trunking Encapsulation: dot1q

Operational Trunking Encapsulation: dot1q

Negotiation of Trunking: Disabled

Access Mode VLAN: 0 ((Inactive))

Trunking Native Mode VLAN: 1 (default)

Trunking VLANs Enabled: ALL

Trunking VLANs Active: 1,10,20

Priority for untagged frames: 0

Override vlan tag priority: FALSE

Voice VLAN: none

Appliance trust: none

sw2#show running-config

!

interface FastEthernet0/0

switchport mode trunk

!

interface FastEthernet0/1

switchport mode trunk

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网