您的位置:首页 > 其它

HSRP,VRRP在企业网中应用

2012-08-16 17:37 477 查看
案例一

1.HSRP基本原理:

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

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

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

HSRP协议利用一个优先级方案来决定哪个配置了HSRP协议的路由器成为默认的主动路由器。如果一个路由器的优先级设置的比所有其他路由器的优先级高,则该路由器成为主动路由器。路由器的缺省优先级是100,所以如果只设置一个路由器的优先级高于100,则该路由器将成为主动路由器。 通过在设置了HSRP协议的路由器之间广播HSRP优先级,HSRP协议选出当前的主动路由器。当在预先设定的一段时间内主动路由器不能发送hello消息时,优先级最高的备用路由器变为主动路由器。路由器之间的包传输对网络上的所有主机来说都是透明的。

2.HSRP实例配置:

运行环境:小凡模拟器,win7

拓扑图





配置

R1配置

line con 0

exec-timeout 0 0 //取消会话超时

logging synchronous //日志同步阻止log干扰

interface FastEthernet0/0

no shutdown //开启端口

interface FastEthernet0/0.10

encapsulation dot1Q 10 //协议封装为dot1q

ip address 192.168.10.1 255.255.255.0

standby 10 ip 192.168.10.254 //配置虚拟ip

standby 10 priority 120 //设置优先级(默认100)

interface FastEthernet0/0.20

encapsulation dot1Q 20

ip address 192.168.20.1 255.255.255.0

standby 20 ip 192.168.20.254

R2配置

line con 0

exec-timeout 0 0

logging synchronous

interface FastEthernet0/0

no shutdown

interface FastEthernet0/0.10

encapsulation dot1Q 10

ip address 192.168.10.2 255.255.255.0

standby 10 ip 192.168.10.254

interface FastEthernet0/0.20

encapsulation dot1Q 20

ip address 192.168.20.2 255.255.255.0

standby 20 ip 192.168.20.254

standby 20 priority 120

SW-1配置

no ip routing //取消路由功能

line con 0

exec-timeout 0 0

logging synchronous

interface Port-channel1

switchport mode trunk //端口模式为trunk

interface FastEthernet0/0

switchport mode trunk

interface FastEthernet0/1

switchport mode trunk

channel-group 1 mode on //加入通道组

interface FastEthernet0/2

switchport mode trunk

channel-group 1 mode on

vlan datase

vlan 10 //vlan10加入数据库

vlan 20 //vlan20加入数据库

int range f0/3 -10

switchport access vlan 10 //将端口3-10加入vlan10

int rang f0/11 -15

switchport access vlan 20 //将端口11-15加入vlan20

SW-2配置

no ip routing

interface Port-channel1

switchport mode trunk

interface FastEthernet0/0

switchport mode trunk

interface FastEthernet0/1

switchport mode trunk

channel-group 1 mode on

interface FastEthernet0/2

switchport mode trunk

channel-group 1 mode on

vlan datase

vlan 10

vlan 20

int range f0/3 –10

switchport access vlan 10

int range f0/11 -15

interface FastEthernet0/0

switchport mode trunk

switchport access vlan 20

测试









案例

1、基本原理

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

VRRP实例配置:

运行环境:2台路由器 2台交换机 2台PC

拓扑图





配置

r1配置

interface Ethernet1.10

vlan-type dot1q vid 10 //封装为dot1q

ip address 192.168.10.1 255.255.255.0

vrrp vrid 10 virtual-ip 192.168.10.254

vrrp vrid 10 priority 120

interface Ethernet1.20

vlan-type dot1q vid 20 //封装为dot1q

ip address 192.168.20.1 255.255.255.0 // 配置ip

vrrp vrid 20 virtual-ip 192.168.20.254 //配置虚拟ip

r2配置

interface Ethernet1.10

vlan-type dot1q vid 10

ip address 192.168.10.2 255.255.255.0

vrrp vrid 10 virtual-ip 192.168.10.254

interface Ethernet1.20

vlan-type dot1q vid 20 //封装为dot1q

ip address 192.168.20.2 255.255.255.0

vrrp vrid 20 virtual-ip 192.168.20.254

vrrp vrid 20 priority 120 //设置优先级

sw-1配置

vlan 10

port e0/5 to e0/10 //创建vlan10

vlan 20 //创建vlan20

port e0/15 to e0/20

interface Ethernet0/1

port link-type trunk

port trunk permit vlan all

interface Ethernet0/5

port access vlan 10

interface Ethernet0/24

port link-type trunk //trunk模式

port trunk permit vlan all //允许所有vlan通过

sw-2配置

vlan 10

port e0/5 to e0/10 //创建vlan10

vlan 20 //创建vlan20

port e0/15 to e0/20

interface Ethernet0/1

port link-type trunk

port trunk permit vlan all

interface Ethernet0/24

port link-type trunk

port trunk permit vlan all

测试

PC1上测试













PC2上测试












本文出自 “uodekoaix” 博客,请务必保留此出处http://uodekoaix.blog.51cto.com/5627685/965137
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: