您的位置:首页 > 其它

VRRP

2018-04-11 08:58 99 查看
虚拟路由器冗余协议
 VRRP(Virtual Router Redundancy Protocol,虚拟路由冗余协议)是一种容错协议。通常,一个网络内的所有主机都设置一条缺省路由。它可以把一个虚拟路由器的责任动态分配到局域网上的 VRRP 路由器中的一台。控制虚拟路由器 IP 地址的 VRRP 路由器称为主路由器,它负责转发数据包到这些虚拟 IP 地址。一旦主路由器不可用,这种选择过程就提供了动态的故障转移机制,这就允许虚拟路由器的 IP 地址可以作为终端主机的默认第一跳路由器。使用 VRRP 的好处是有更高的默认路径的可用性而无需在每个终端主机上配置动态路由或路由发现协议。 VRRP 包封装在 IP 包中发送。
 VRRP协议的工作机理与CISCO公司的HSRP(Hot Standby Routing Protocol)有许多相似之处。但二者主要的区别是在CISCO的HSRP中,需要单独配置一个IP地址作为虚拟路由器对外体现的地址,这个地址不能是组中任何一个成员的接口地址。使用VRRP协议,不用改造目前的网络结构,最大限度保护了当前投资,只需最少的管理费用,却大大提升了网络性能,具有重大的应用价值。
    vrrp只定义了一种报文——vrrp报文,这是一种组播报文,由主三层交换机定时发出来通告他的存在。使用这些报文可以检测虚拟三层交换机各种参数,还可以用于主三层交换机的选举。
 VRRP中定义了三种状态模型,初始状态Initialize,活动状态Master和备份状态Backup,其中只有活动状态的交换机可以为到虚拟IP地址的的转发请求提供服务。
 vrrp报文是封装在IP报文上的,支持各种上层协议,同时VRRP还支持将真实接口IP地址设置为虚拟IP地址。 
 虚拟交换机根据配置的优先级的大小选择主交换机,优先级最大的作为主交换机,状态为Master,若优先级相同(如果交换机没有配置优先级,就采用默认值100),则比较接口的主IP地址,主IP地址大的就成为主交换机,由它提供实际的路由服务。其他交换机作为备份交换机,随时监测主交换机的状态。当主交换机正常工作时,它会每隔一段时间发送一个VRRP组播报文,以通知组内的备份交换机,主交换机除正常工作状态。如果组内的备份交换机长时间没有接收到来自主交换机的VRRP组播报文,则将自己状态转换为Master。当组内有多台备份交换机,将有可能产生多个主交换机。这时每一个主交换机就会比较VRRP报文中的优先级和自己本地的优先级,如果本地的优先级小于VRRP中的优先级,则将自己的状态转换为Backup,否则保持自己的状态不变。通过这样一个过程,就会将优先级最大的交换机选成新的主交换机,完成VRRP的备份功能。
 最典型的VRRP应用:RTA、RTB组成一个VRRP路由器组,假设RTB的处理能力高于RTA,则将RTB配置成IP地址所有者,H1、H2、H3的默认网关设定为RTB。则RTB成为主控路由器,负责ICMP重定向、ARP应答和IP报文的转发;一旦RTB失败,RTA立即启动切换,成为主控,从而保证了对客户透明的安全切换。  
 在VRRP应用中,RTB在线时RTA只是作为后备,不参与转发工作,闲置了路由器RTA和链路L1。通过合理的网络设计,可以到达备份和负载分担双重效果。让RTA、RTB同时属于互为备份的两个VRRP组:在组1中RTA为IP地址所有者;组2中RTB为IP地址所有者。将H1的默认网关设定为RTA;H2、H3。
 spanning-tree 开启生成树(默认为mstp)  
 spanning-tree mst configuration 进入mst配置模式  
 revision 1 指定MST revision number 为1  
 name region1 指定mst配置名称  
 instance 0 vlan 1-9, 11-19, 21-4094 缺省情况下vlan都属于实例0  
 instance 1 vlan 10 手工指定vlan10属于实例1  
 instance 2 vlan 20 手工指定vlan20属于实例2  
 spanning-tree mst 1 priority 0 指定实例1的优先级为0(为根桥)  
 spanning-tree mst 2 priority 4096 指定实例2的优先级为4096  
 interface GigabitEthernet 0/1  
 switchport access vlan 10 配置g0/1属于vlan10 
 interface GigabitEthernet 0/2  
 switchport access vlan 20 配置g0/2属于vlan 20  
 interface GigabitEthernet 0/3 
 interface GigabitEthernet 0/24 设置g0/24为trunk接口且允许vlan10/20通过  switchport mode trunk 
 interface VLAN 10 创建vlan 10 svi接口  
 ip address 192.168.10.1 255.255.255.0 配置ip地址  
 vrrp 1 priority 120 配置vrrp组1 优先级为120  
 vrrp 1 ip 192.168.10.254 配置vrrp组 1虚拟ip地址为 192.168.10.254                                 interface VLAN 20 创建vlan 20 svi接口  
 ip address 192.168.20.1 255.255.255.0 配置ip地址  
 vrrp 2 ip 192.168.20.254 配置vrrp组 2虚拟ip地址为 192.168.20.254
 



R1:
    aaa-enable
    aaa accounting-scheme optional
    vrrp ping-enable
  acl 2000 match-order auto
    rule normal permit source 192.168.10.0 0.0.0.255
    rule normal permit source 192.168.20.0 0.0.0.255
  interface Aux0
    async mode flow
    link-protocol ppp
  interface Ethernet0.10
    vlan-type dot1q vid 10
    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 Ethernet0.20
    vlan-type dot1q vid 20
    ip address 192.168.20.1 255.255.255.0
    vrrp vrid 20 virtual-ip 192.168.20.254
  interface Ethernet1
  interface Serial0
    link-protocol ppp
  interface Serial1
    link-protocol ppp
    ip address 192.168.30.2 255.255.255.0
    nat outbound 2000 interface
  interface Async0
    physical-mode async
    async mode protocol
    link-protocol ppp
  interface Async7
    physical-mode async
    async mode protocol
    link-protocol ppp
  voice-setup
    subscriber-line 0
    subscriber-line 1
   
  ip route-static 0.0.0.0 0.0.0.0 192.168.30.1 preference 60R2:
    aaa-enable
    aaa accounting-scheme optional
    vrrp ping-enable
  acl 2000 match-order auto
    rule normal permit source 192.168.10.1 0.0.0.255
    rule normal permit source 192.168.20.1 0.0.0.255
  interface Aux0
    async mode flow
    link-protocol ppp
  interface Ethernet0
    ip address 192.168.100.9 255.255.255.0
  interface Ethernet0.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 Ethernet0.20
    vlan-type dot1q vid 20
    ip address 192.168.20.2 255.255.255.0
    vrrp vrid 20 virtual-ip 192.168.20.254
    vrrp vrid 20 priority 120
    vrrp vrid 20 track Serial1 reduced 30
  interface Serial0
    link-protocol ppp
  interface Serial1
    clock DTECLK1
    link-protocol ppp
    ip address 192.168.40.2 255.255.255.0
    nat outbound 2000 interface
  interface Async0
    physical-mode async
    async mode protocol
    link-protocol ppp
  interface Async15
    physical-mode async
    async mode protocol
    link-protocol ppp
  ip route-static 0.0.0.0 0.0.0.0 192.168.40.1 preference 60
 
ISP:
    aaa-enable
    aaa accounting-scheme optional
  interface Aux0
    async mode flow
    link-protocol ppp
  interface Ethernet0
    ip address 192.168.100.10 255.255.255.0
  interface Serial0
    link-protocol ppp
    ip address 192.168.40.1 255.255.255.0
  interface Serial1
    clock DTECLK1
    link-protocol ppp
    ip address 192.168.30.1 255.255.255.0
  interface LoopBack1
    ip address 2.2.2.2 255.255.255.0SW1:
vlan 10
vlan 20
interface Vlan-interface1
 ip address 192.168.100.33 255.255.255.0
interface Aux0/0
interface Ethernet0/1
 port link-type trunk
 port trunk permit vlan all
interface Ethernet0/2
 port link-type trunk
 port trunk permit vlan all
interface Ethernet0/24
 port link-type trunk
 port trunk permit vlan all
interface NULL0
user-interface aux 0
user-interface vty 0 4
 authentication-mode schemeSW2: 
vlan 10
vlan 20
interface Vlan-interface1
 ip address 192.168.100.41 255.255.255.0
interface Aux0/0
interface Ethernet0/1
 port link-type trunk
 port trunk permit vlan all
interface Ethernet0/2
 port link-type trunk
 port trunk permit vlan all
interface Ethernet0/24
 port link-type trunk
 port trunk permit vlan all
interface NULL0
user-interface aux 0
user-interface vty 0 4
 authentication-mode none
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  VRRP