当前位置:首页>微思动态 > >详情
全国热线电话 400-881-4699

在线留言

【干货】思科路由器备份配置HSRP

发布作者:微思网络   发布时间:2017-11-17   浏览量:0

对于某些企业或组织的某些关键业务数据的网络传输,要求网络设备高度的可靠性,而且需要维护方便。 
       Cisco路由器的备份技术有多种。这里介绍一下厦门CCIE培训多少钱及路由器自身的备份技术及线路备份技术。


    一般来说,路由器是建立局域网与广域网连接的桥梁。 
    所谓的路由器自身的备份技术是为了解决路由器由于自身硬件(如内存、CPU)或软件IOS的某种故障或局域端口的故障,所连接局域设备的端口或线路的故障所导致的网络瘫痪的问题。 
    路由器的备份要求至少有一台与正在工作的主路由器功能相同的路由器,在主路由器瘫痪的情况下,以某种方式代替主路由器,为局域网用户提供路由服务。 
    对于局域网的计算机,在主路由器瘫痪的情况下,如何找到备份路由器,主要有以下集中办法: 
    ·proxy ARP 
    ·IRDP 
    ·动态路由 
    ·HSRP 
         ·Proxy ARP
 
    支持Proxy ARP 的计算机无论与本网段的计算机还是不同网段的计算机进入通讯都发送ARP广播以寻找与目的地址相对应的MAC地址,这时,知道目的地址的路由器会响应ARP的请求,并将自己的MAC地址广播给源计算机,然后源计算机就将IP数据包发给该路由器,并由路由器最终将数据包发送到目的。 
  在主路由器瘫痪情况下,计算机再进行通讯时,它将继续发送Proxy ARP广播,备份路由器响应该请求,并进行数据传输。 
  
    缺点: 
    如果主路由器正在传输数据时瘫痪,正在通信的计算机在未发送另外的Proxy ARP请求之前.根本就无法知道主路由器已瘫痪,会继续向该路由器发包,导致传输中断,正在通信的计算机只有在另外发送Proxy ARP请求或重新启动之后才能找到备份路由器以进行传输。 
    Cisco路由器支持Proxy ARP 
  
  ·IRDP 
    局域网中的支持IRDP的计算机会监听主路由器发出的"Hello"的多点广播信息包,如果该计算机不再收到"Hello"信息时,它就会利用备份路由器进行数据传输。 
  
  ·动态路由 
    对于某些计算机,它们本身支持RIP动态路由以寻找路由器, 这种办法的缺点是主路由器与备份路由器间的转换较慢。 
    以上三种办法,主要都是在计算机一方采用的技术,Cisco路由器提供了HSRP技术,采用这种技术不需要计算机进行任何设置,即对计算机来说,主路由器与备份路由器之间切换是透明的,而且它们之间的切换速度较快。 

   

     采用HSRP进行备份的一组路由器共用一个虚拟的MAC地址及虚拟IP地址,每个参与HSRP的局域端口有一个本端口的IP地址和MAC地址,每个路由器都有一个权值,权值最高的作为主路由器进行工作,其它的不工作,当主路由器瘫痪时,第二个权值最高的路由器将作为主路由器,依次类推。路由器之间定期交换权值信息以确定路由器的工作状态。如果主路由器在一段时间内不发送这种信息包,其它备份路由器将认为该路由器已坏,权值电高的备份路由器将接管虚拟MAC地址和IP地址,并负责传输数据。一旦主路由器恢复正常,将自动切换回去,重新接管传输数据的工作,之后备份路由器停止传输,处于备份状态。另外,HSRP允许路由器对某些端口的工作状态进行监测,一旦这个端口出现故障,也进行自动切换。 
  
    总之,对于局域网的计算机,它们的网关只有一个,即虚拟 IP 地址。所有的备份工作都由路由器自动完成。 
    HSRP适应于主路由器与备份路由器的线路完全一致的情况。 
    使用HSRP功能,建议采用收敛速度较快的动态路由协议,如OSPF,EIGRP。 
  
  HSRP基本配置步骤: 
    1. 在端口配置下,设置端口 IP 地址, 
      ip address端口 IP 地址 子网掩码 
    2. 在端口配置下,启用 HSRP 功能,并设置虚拟 IP 地址 
      standby 组号 IP 虚拟 IP 地址 
    其中只有有相同组号的路由器属于同一个hsrp组,所有属于同一个hsrp组的路由器的虚拟地址必须一致 
    3. 在端口设置状态下设置HSRP抢占 
      standby 组号 preempt 
    该设置允许权值高于该hsrp组的其它路由器成为主路由器。所有该给路由器都应该设置此项,以便每台路由器都可以成为其它路由器的备份路由器。如果不设置该项,即使用该路由器权值再高,也不会成为主路由器。 
    4. 设置路由器的hsrp权值 
      standby 组号 priority 权值 
    如果不设置该项,缺省权值为100,其中权值数字大,则抢占为主路由器的优先权越高。 
    5. 设置hsrp组路由器身份验证字符串 
      standby 组号 authentication 字符串 
  
    该项设置为可选设置,如果设置该项,则该hsrp组的所有路由器都必须进行该项设置,且只有有相同字符串的该组路由器才能进行hsrp。 
  
    6. 设置hsrp切换时间 
      standby 组号 时间参数1 时间参数2 
  
    其中时间参数1表示路由器每间隔多长时间交换一次hello信息,以表明路由器是否出现故障或工作正常。时间参数2表示在多长时间内同组的其他路由器没有收到主路由器的信息,则宣布主路由器瘫痪。该设置的缺省值分别为3秒和10 秒。如果要更改缺省值,所有同hsrp组的路由器的该项设置必须一致。 
  
    7. 端口跟踪设置 
      standby 组号 track 端口号 
    该项设置为可选设置 
    该设置表示如果所监测的端口出现故障,则也进行路由器的切换。可以跟踪多外端口。 
  
    注意:如果主路由器上有多条线路被跟踪,则有一条线路出现故障时,就会切换到备份路由器上,即使其他都正常工作,直到主路由器该线路正常工作,才能重新发换过来。该项设置实现的功能在实际应用中完全可以由线路备份功能实现,而且在大多数情况下,该项设置也没有多大意义。 
  另外,hsrp还有很多其它设置及应用,如感兴请在Cisco站点或Cisco Document上查找,或与晓通技术支持中心联系。 
  
  
  ★ 实例: 
  2511-1与2511-2互为路由器备份 
  
  2511-1的配置
  2511-1#sho run 
  Building configuration… 
  
  Current configuratoin: 
  ! 
  version 11.3 
  no service password -encryption 
  ! 
  hostname 251l-l 
  ! 
  enable password cisco 
  ! 
  username 2505 password 0 cisco 
  no ip domain-lookup 
  ! 
  interface Ethernet0 
  ip address 192.4.1.99 255.255.255.0 
  no ip redirects 
  standby 1 timers 5 15 
  standby 1 priority 110 
  standby 1 preempt 
  standby 1 authentication cisco 
  standby 1 ip 192.4.1.1 
  standby 1 track Serial0 
  standby 1 track Seriall 
  ! 
  interface serial0 
  ip address l92.3.1.1 255.255.255.0 
  encapsulation frame-relay IETF 
  ip ospf message-digest-key 1 md5 kim 
  no ip mroute-cache 
  bandwidth 2000 
  frame-relay map ip 192.3.1.2 100 broadcast 
  frame-relay lmi-type cisco 
  ! 
  interface Serial1 
  ip address 192.7.l.l 255.255.2550 
  encapesulation ppp 
  ip ospf message-digest-key 1 md5 kim 
  ip ospf network non-broadcast 
  bandwidth 64 
  ppp authentication chap 
  ! 
  router ospf 1 
  passive-interface Ethernet0 
  network 192.3.1.0 0.0.0.255 area 0 
  network 192.4.l.0 0.0.0.255 area 0 
  network 192.7.l.0 0.0.0.255 area 0 
  neighbor 192.7.1.2 priority 1 
  neighbor 192.3.1.2 priority 1 
  area 0 authentication message-digest 
  ! 
  no ip classless 
  ! 
  line con 0 
  line 1 8 
  line aux 0 
  line vty 0 4 
  password cisco 
  login 
  ! 
  end 
  
  2511-2的配置 
  2511-2#sho run 
  Building configuration... 
  Current configuration: 
  ! 
  version 11.3 
  no servicc password-encryption 
  ! 
  hostname 2511-2 
  enable secret 5 $1$7o5F$MSyFWzVf6JBgnjLJghHSB. 
  ! 
  ! 
  interface Ethernet0 
  ip address 192.4.1.lOO 255.255.255.0 
  no ip redirects 
  standby 1 timers 5 15 
  standby 1 priority 100 
  staidby 1 preempt 
  standby 1 authentication cisco 
  sandby 1 ip 192.4.1.1 
  ! 
  interface Serial0 
  ip address 192.8.1.2 255.255.255.0 
  encapsulation x25 
  ip ospf missage-digest-key 2 md5 cisco 
  no ip mroute-cache 
  x25 address 5678 
  x25 htc 16 
  x25 nvc 4 
  x25 map ip 192.8.l.1 1234 broadcast 
  ! 
  interface Serial1 
  no ip address 
  no ip mroute-cachc 
  bandwidth 2000 
  clockrate 2000000 
  ! 
  router ospt 1 
  passive-interface Ethernet0 
  network 192.8.1.0 0.0.0.255 area 0 
  network 192.4.1.0 0.0.0.255 area 0 
  neighbor 192.8.1.1 priority 1 
  area 0 authentication message-digest 
  ! 
  ip classless 
  ! 
  line con 0 
  line 1 8 
  line aux 0 
  line vty 0 4 
  login 
  ! 
  end 
  
  2514的配置 
  2514# sho run 
  Building configuration... 
  ! 
  Current configuration: 
  ! 
  version 11.2 
  no service udp-small-servers 
  no service tcp-small-servers 
  ! 
  hostname 2514 
  ! 
  enable secret 5 $1$uoHU$Vks/1YCRi33z4TXs4qekI0 
  ! 
  frame-relay switching 
  ! 
  interface Ethernet0 
  no ip address 
  ! 
  interface Ethernet1 
  no ip address 
  shutdown 
  ! 
  interfacc Serial0 
  ip address 192.3.1.2 255.255.255.0 
  encapsulation frame-relay IETF 
  ip ospf message-digest-key 1 md5 kim 
  bandwidth 2000 
  clockrate 2000000 
  frame-relay map ip 192.3.1.1 100 broadcast 
  frame-relay intf-type dce 
  ! 
  interface Serial1 
  ip address 192.8.1.1 255.255.255.0 
  no ip mroute-cache 
  enthpsulation x25 dce 
  ip ospf message-digest-key 2 md5 cisco 
  bandwidth 64 
  x25 address 1234 
  x25 htc 16 
  x25 nvc 4 
  x25 map ip 192.8.1.2 5678 broadcast 
  clockrate 64000 
  ! 
  router ospf 1 
  passive-interface Ethernet0 
  network 192.3.1.0 0.0.0.255 area 0 
  network 192.8.1.O 0.0.0.255 area 0 
  neighbor 192.8.l.2 priority 1 
  neighbor 192.3.1.1 priority 1 
  area 0 authentication message-digest 
  ! 
  no ip classless 
  ! 
  line con 0 
  line aux 0 
  line vty 0 4 
  login 
  ! 
  end 
  
  2505的配置 
  building configuraiion... 
  Current configuration:! 
  version 11.2 
  no service udp-small-servers 
  no service tcp-small-servers 
  ! 
  hostname 2505 
  ! 
  enable secret 5 $1$b43o$CpEYSTc2EPwnRlQGDvIm// 
  ! 
  username 2511-1 password 7 1511021F0725 
  ! 
  hub ether 0 1 
  link-test 
  auto-polarity 
  ! 
  hub ether O 2 
  link-test 
  auto-polarity 
  ! 
  hub ether 0 3 
  link-test 
  auto-polarity 
  ! 
  hub ether 0 4 
  link-test 
  auto-polarity 
  ! 
  hub ether 0 5 
  link-test 
  auto-polarity 
  ! 
  hub ether 0 6 
  link-test 
  auto-polarity 
  ! 
  hub ether 0 7 
  link-test 
  auto-polarity 
  ! 
  hub ether 0 8 
  link-test 
  auto-polarity 
  ! 
  interface Ethernet0 
  ip address 192.1.4.1 255.255.255.0 
  ! 
  interfacc Serial0 
  ip address 192.l.2.1 255.255.255.0 
  ip ospf message-digest-key 1 md5 cisco 
  ip ospf network non-broadcast 
  bandwidth 2000 
  clockrate 2000000 
  ! 
  interface Serial1 
  ip address 192.7.1.2 255.255.255.0 
  encapsulation ppp 
  ip ospf message-digdest-key 1 md5 kim 
  ip ospf network non-broadcast 
  bandwidth 64 
  clockrate 64000 
  ppp authentication chap 
  ! 
  router ospf 1 
  passive-interface Ethernet0 
  network 192.l.2.0 0.0.0.255 area 2 
  network 192.l.4.O 0.0.0.255 area 2 
  network 192.7.1.0 0.0.0.255 area 0 
  neighbor 192.7.l.1 priority 1 
  neighbor 192.1.2.2 priority 1 
  area 0 authentication message-digest 
  area 2 authentication message-digest 
  area 2 range 192.1.0.0 255.255.0.0 
  ! 
  no ip classless 
  ip ospf name-lookup 
  ! 
  line con 0 
  line aux 0 
  Iine vty 0 4 
  login 
  ! 
    end

              线路备份 其实,在广域网连接中,最不可靠的因素大多数情况下是出在线路、端口及外接的设备上。相对来说线路备份更为重要。 
    线路备份一般有几种主要方法: 
    · 采用动态路由自动进行备份 
    · 采用显示backup(备份)方法进入备份 
    · 采用浮动的静态路由方法进行备份 

  
    方法1是在网络中含有多条冗余线路,路由器通过动态路由学习到所有线路工作情况.根据路由算法选择最优的路径作为主干线路,一旦某条主干线路出现故障,路由器将在一段时间过后,自动删除通过该条线路的路径,重新进行最优路径计算,重新选择一条通过某条冗余线路的最优的路径。所有这些过程,都由动态路由协议自动完成,无须任何其它设置。 
  
    方法2 显示backup备份方法 
    该种方法显示的指明哪条主干线路,哪一条是备份线路。如果主干线路出现故障,则在指定的时间内,备份线路会代替主干线路工作。如果主干线路恢复正常,则在指定的时间过后,会自动切换回主干线路备份线路重新处于备份状态。 
    设置为显示备份后,路由器将监测CD信号,一旦CD信号消失,则路由器便认为该线路出现故障。如果CD 信号始终存在,则路由器认为主干线路工作正常。 
    这种备方法适用于DDN专线作主干线路的情况。因为对于DDN专线,如果线路断掉,则两边的路由器的CD信号都会消失,而该种方去不适用于X.25线路上,因为X.25线路上出现故障时,大多数情况下都是建立不起来虚电路,而CD信号则往往存在。而且,如果一端X.25线路出现故障,而另一端X.25线路往往是正常的,这样,如果正常一端的路由器有数据传送给不正常一端时,路由器认为X.25线路工作正常。因此根本不会起备份线路。 
  
  显示备份方法配置步骤 
  
  1.正确配置主干线路能正常通信 
  2.然后正确配置备份线路能正常通信 
  3.在主干线路所连接的端口中显示指出哪一条线路为备份线路 
  backup interface 备份线路端口号 
  4.指定在主干线路出现故障多长时间后启用备份线路及在主干线路恢复正常多长时间后切换回主干线路。备份线路恢复到备份状态 
  backup delay 时间参数1(秒) 时间参数字2(秒) 
  
    时间参数1指定在主干线路出现故障多长时间后启用备份线路,时间参数2指定在主干线路恢复正常多长时间后切换回主干线路,备份线路恢复到备份状态。 
  
    设置备份线路的路由可以起任何方式的路由,但备份线路一般带宽相对主干线路较低,且如果起动态路由会有额外费用。因此,一般在备份线路上使用静态路由。 
  在全局设置模式下 
    ip route 目地子网地址 子网掩码 相邻路由器相邻端口地址 
    原则上讲,备份线路可以为任何线路。但一般都是用带宽相对较低,费用较低的线路作为备份线路。 
    一般的,可以用X.25或PSTN作DDN线路的备份。 
    以下实例为用Cisco2501 AUX口作模拟DDN专线的拨号备份. 
  
  实例: 
  
  Cisco 2501-above 的配置 
  Current configuration: 
  ! 
  version 11.2 
  no service udp-small-servers 
  no service tcp-small-servers 
  ! 
  hostname above 
  ! 
  Current configuration: 
  ! 
  version 11.2 
  no service udp-small-servers 
  no service tcp-small-servers 
  ! 
  hostname above 
  ! 
  enable secret 5 $1$O1aq$Kxgp1A0Eulqug8SbCm6rdl 
  enable password cisco 
  ! 
  username down password 7 095C5E19 
  chat-script lab ABORT ERROR ABORT BUSY ABORT "NO ANSWER" "" "AT H" OK "ATDT \T" 
  TIMEOUT 60 CONNECT \c 
  ! 
  interface Ethernet0 
  ip address 192.192.193.1 255.255.255.0 
  !interface Serial0 
  ip address 192.192.192.1 255.255.255.0 
  bandwidth 64 
  clockrate 64000 
  ! 
  interface Serial1 
  no ip address 
  shutdown 
  ! 
  interface Async1 
  ip address 166.71.70.1 255.255.255.0 
  encapsulation ppp 
  async dynamic address 
  async dynamic routing 
  async mode dedicated 
  dialer in-band 
  dialer map ip 167.71.70.2 name down moden-script lab broadcast 3631 
  dialer-group 1 
  no cdp enable 
  ppp authentication chap 
  ! 
  router rip 
  network l92.192.192.0 
  nctwork 192.192.193.0 
  ! 
  no ip classless 
  ip route 0.0.0.0 0.0.0.0 166.71.70.2 
  ip routc 192.192.191.0 255.255.255.0 166.71.70.2 
  dialer-list 1 protocol ip permit 
  ! 
  line con 0 
  line aux 0 
  modem InOut 
  modem autoconfigure discovery 
  stopbits 1 
  rxspeed 38400 
  txspeed 38400 
  flowcontrol hardware 
  line vty 0 4 
  no login 
  ! 
  end 
  
  
  !Cisco 2501 named down configuration 
  Cisco 2501-down 的配置 
  Current configuration: 
  ! 
  version 11.2 
  no service udp-small-servers 
  no servicc tcp-small-servers 
  ! 
  hostname down 
  ! 
  enable secret 5 $1$m8S4$lnrkhnJDtCVtSvTpXO8v/0 
  enable password cisco 
  ! 
  username above password 7 095C5E19 
  chat-script lab ABORT ERROR ABORT BUSY ABORT "NO ANSWER" "" "AT H" OK "ATDT \T" TIMEOUT 60 CONNECT \C 
  ! 
  interface Ethernet 0 
  ip address 192.192.191.1 255.255.255.0 
  ! 
  interface Serial0 
  backup delay 10 10 
  backup interface Async1 
  ip address 192.192.192.3 255.255.255.0 
  !interface Seriall 
  no ip address 
  shutdown 
  ! 
  interface Async1 
  ip address 166.71.70.2 255.255.255.0 
  encapsulation ppp 
  async dynamic address 
  async dynamic routing 
  async mode dedicated 
  dialer in-band 
  dialer map ip 166.71.70.1 name above modem-script lab broadcast 3621 
  dialer-group 1 
  no cdp enable 
  ppp authentication chap 
  ! 
  router rip 
  net work 192.192.192.0 
  net work 192.192.191.0 
  ! 
  no ip classless 
  ip route 0.0.0.0 0.0.0.0 166.71.70.1 
  ip route 192.192.193.0 255.255.255.0 166.71.70.1 
  dialer-list 1 protocol ip permit 
  ! 
  line con 0 
  line aux 0 
  modem InOut 
  modem autoconfigure discovery 
  stopbits 1 
  rxspeed 38400 
  txspeed 38400 
  flowcontrol hardware 
  line vty 0 4 
  no login 
  
    !

方法3:浮动的静态路由作备份。缺省状态下,Cisco路由器选择路由的顺序为静态路由,动态路由,缺省路由,这是由各种路由的权值决定的。 
可以手动改变静态路由的权值大小,使得其可以在动态路由之后,该静态路由就成为浮动的静态路由。如果在动态路由表中找不到相应有路由时,浮动的静态路由才可以被选中,以传输数据。一般的,对于X.25线路用浮动的静态路由作拨号备份,特别适合。不过,用浮动的静态路由可以用任何线路备份其他任何线路。 
注意:用浮动的静态路由作X.25线路的备份线路则X.25线路必须起动态路由,否则无法实现双向备份。 
    浮动静态路由配置步骤: 
    1、正确配置主干线路,保证其能正常通信 
    2、配置主干线路的动态路由 
    3、正确配置备份线路,保证其能正常通信 
    4、配置通过备份线路的浮动静态路由 
    ip route 目地子网地址 子网掩码 相邻路由器相邻端口地址 权值 
    其中,权值数值越高其路由优先权越低权值范围在1-255之间 
  
 

  实例: 

  COSCO 2501-above的配置 
  Current confignration: 
  ! 
  version 11.2 
  no service udp-small-servers 
  no service tcp-small-servers 
  ! 
  hostname above 
  ! 
  enable secret 5 $1$O1aq$KxgpIA0Eulqug8SbCm6rd1 
  enable password cisco 
  ! 
  username down password 7 095C5E19 
  chat-scrip lab ABORT ERROR ABORT BUSY ABORT "NO ANSWER" "" "AT H" OK "ATDT \T" TIMEOUT 60 CONNECT \c 
  ! 
  interface Ethernet0 
  ip address 192.192.193.1 255.255.255.0 
  ! 
  interface Serial0 
  iu address 192.192.192.1 255.255.255.0 
  bandwidth 64 
  clockrate 64000 
  ! 
  interface Scrial1 
  no ip address 
  shutdown 
  interface Asyncl 
  ip address 166.71.70.1 255.255.255.0 
  encapsulation ppp 
  async dynamic address 
  async dynamic routing 
  async mode dedicated 
  dialer in-band 
  dialer ip 166.71.70.2 name down modem-script lab broadcast 3631 
  dialer-group 1 
  no cdp enable 
  ppp authentication chap 
  ! 
  router rip 
  network 192.192.192.0 
  network 192.192.193.0 
  ! 
  no ip classless 
  ip route 0.0.0.0 0.0.0.0 166.71.70.2 150 
  ip route 192.192.191.0 255.255.255.0 166.71.70.2 150 
  dialer-list 1 protocol ip permit 
  ! 
  line con 0 
  line aux 0 
  modem InOut 
  modem autoconfigure discovery 
  stopbits 1 
  rxspeed 38400 
  txspeed 38400 
  flowcontrol hardware 
  line vty 0 4 
  no login 
  ! 
  end 
  
  
  Cisco 2501-down 的配置 
  
  Current configuration: 
  ! 
  version 11.2 
  no service udp-small-servers 
  no service tep-small-servers 
  ! 
  hostname down 
  ! 
  enable secret 5 $1$m8S4$InrkhnJDtCVtSvTpXO8v/0 
  enable password cisco 
  ! 
  username above password 7 095C5E19 
  chat-script lab ABORT ERROR ABORT BUSY ABORT "NO ANSWER" "" "AT H" OK "ATDT \T" TIMEOUT 60 CONNECT \c 
  ! 
  interface Ethernet0 
  ip address 192.192.191.1 255.255.255.0 
  ! 
  interface Serial0 
  ip address 192.192.192.3 255.255.255.0 
  
  ! 
  interface Serial1 
  no ip address 
  shutdown 
  ! 
  interface Asyncl 
  ip address 166.71.70.2 255.255.255.0 
  encapsulation ppp 
  async dynamic address 
  async dynamic routing 
  async mode dedicated 
  dialer in-band 
  dialer map ip 166.71.70.1 name above modem-script lab broadcast 3621 
  dialer-group 1 
  no cdp enable 
  ppp authentication chap 
  ! 
  router rip 
  network 192.192.192.0 
  network 192.192.191.0 
  ! 
  no ip classless 
  ip route 0.0.0.0 0.0.0.0 166.71.70.1 150 
  ip route 192.192.193.0 255.255.255.0 166.71.70.1 150 
  dialer-list 1 protocol ip permit 
  ! 
  line con 0 
  line aux 0 
  modem InOut 
  modem autoconfigure discovery 
  stopbits 1 
  rxspeed 38400 
  txspeed 38400 
  flowcontrol hardware 
  line vty 0 4 
  no login



返回顶部