案例一
随着Internet的日益普及,人们对网络的依赖性也越来越强。这同时对网络的稳定性提出了更高的要求,人们自然想到了基于设备的备份结构,就像在服务器中为提高数据的安全性而采用双硬盘结构一样。路由器是整个网络的核心和心脏,如果路由器发生致命性的故障,将导致本地网络的瘫痪,如果是骨干路由器,影响的范围将更大,所造成的损失也是难以估计的。因此,对路由器采用热备份是提高网络可靠性的必然选择。在一个路由器完全不能工作的情况下,它的全部功能便被系统中的另一个备份路由器完全接管,直至出现问题的路由器恢复正常,这就是热备份路由协议(HotStandbyRouterProtocol),HSRP-RFC2281技术要解决的问题
HSRP:热备份路由器协议(HSRP:Hot Standby Router Protocol),是cisco平台一种特有的技术,是cisco的私有协议。热备份路由协议(HSRP)的设计目标是支持特定情况下 IP 流量失败转移不会引起混乱、并允许主机使用单路由器,以及即使在实际第一跳路由器使用失败的情形下仍能维护路由器间的连通性。换句话说,当源主机不能动态知道第一跳路由器的 IP 地址时,HSRP 协议能够保护第一跳路由器不出故障。
案例拓补图
 

Hsrp 和vrrp在企业网中的应用_安全性

实验所需设备
两台cisco路由器,两台交换机作为核心层交换机,两台交换机作为接入层的交换机,还有4台pc作为测试用的设备
实验用到的命令
路由器的配置命令
Router>enable
Router#configure terminal
Router(config)#interface fastEthernet 0/0
Router(config-if)#no shutdown
Router(config)#interface fastEthernet 0/0.10
Router(config-subif)#encapsulation dot1Q 10
Router(config-subif)#ip address 192.168.10.1 255.25.255.0
Router(config-subif)#standby ip 192.168.10.254(配置虚拟网关)
Router(config-subif)#standby 10 priority 120(设置优先级)
Router(config)#interface fastEthernet 0/0.20
Router(config-subif)#encapsulation dot1Q 20
Router(config-subif)#ip address 192.168.20.1 255.255.255.0
Router(config-subif)#standby ip 192.168.20.254
Router(config-subif)#standby 10 priority 120
R1的配置结果
R1(config)#do show run
Building configuration...
 
Current configuration : 779 bytes
!
version 12.4
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname R1
!
boot-start-marker
boot-end-marker
!
!
no aaa new-model
memory-size iomem 5
!
!
ip cef
!
interface FastEthernet0/0
 no ip address
 duplex auto
 speed auto
!        
interface FastEthernet0/0.10
 encapsulation dot1Q 10
 ip address 192.168.10.1 255.255.255.0
 standby 10 ip 192.168.10.254
 standby 10 priority 120
!
interface FastEthernet0/0.20
 encapsulation dot1Q 20
 ip address 192.168.20.1 255.255.255.0
 standby 20 ip 192.168.20.254
!
ip http server
no ip http secure-server
!
 
!
line con 0
 exec-timeout 0 0
 logging synchronous
line aux 0
line vty 0 4
!
!
End
交换机的配置命令
Router>enable
Router#configure terminal
 
Router(config)#interface fastEthernet 0/0
Router(config-if)#switchport mode trunk
Router(config-if)#switchport trunk allowed vlan all
Router(config-if)#int fa 0/15
Router(config-if)#switchport mode trunk
Router(config-if)#switchport trunk allowed vlan all
交换机的配置结果
SW1(config)#do show run
Building configuration...
 
Current configuration : 1026 bytes
!
version 12.4
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname SW1
!
boot-start-marker
boot-end-marker
!
!
no aaa new-model
memory-size iomem 5
!
!
ip cef
!
interface FastEthernet0/0
 switchport mode trunk
!
interface FastEthernet0/1
 switchport access vlan 10
!
interface FastEthernet0/2
 switchport access vlan 20
!
interface FastEthernet0/3
!
interface FastEthernet0/4
!
interface FastEthernet0/5
!
interface FastEthernet0/6
!
interface FastEthernet0/7
!
interface FastEthernet0/8
!
interface FastEthernet0/9
!
interface FastEthernet0/10
!
interface FastEthernet0/11
!
interface FastEthernet0/12
!
interface FastEthernet0/13
!
interface FastEthernet0/14
!
interface FastEthernet0/15
 switchport mode trunk
!
interface Vlan1
 no ip address
!
ip http server
no ip http secure-server
!
control-plane
 
!
line con 0
 exec-timeout 0 0
 logging synchronous
line aux 0
line vty 0 4
!
!
End
测试的结果
Sending 5, 100-byte ICMP Echos to 192.168.20.254, timeout is 2 seconds:
!!!!!
Router(config)#do ping 192.168.10.254
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.10.254, timeout is 2 seconds:
!!!!!