网关负载均衡协议(GLBP)原理与实验

一、基础知识:
      GLBP是思科的专有协议,设计GLBP的目的是自动选择和同时使用多个可用的网关。和HSRP、VRRP不同的是,GLBP可充分利用资源,同时无需配置多个组和管理多个默认网关配置。
      GLBP组中最多可以有4台路由器作为IP默认网关。这些网关被称为AVF(Active Virtual Forwarder,活跃虚拟转发器)。GLBP自动管理虚拟MAC地址的分配、决定谁负责处理转发工作(这是区别于HSRP和VRRP的关键!回忆一下ARP原理吧~在GLBP中有一个虚拟IP,但对应多个虚拟MAC)。
      默认情况下,GLBP以循环方式根据源主机来均衡负载。
      GLBP支持下列负载均衡模式:
      1.加权负载均衡算法:前往AVF的流量取决于包含该AVF网关通告的权重值。
      2.主机相关负载均衡:确保主机始终使用同一个虚拟MAC地址。
      3.循环负载均衡算法:在解析虚拟IP地址的应答中,将包含各个虚拟转发器的MAC地址,以此让主机将数据发送到不同的路由器上,从而实现了网关负载均衡。
二、配置与验证常用命令
      配置:
      1.将接口配置到指定虚拟IP的虚拟组:
Router(config-if)#glbp group-number ip virtual-gateway-address
      2.配置路由器优先级,优先级高的为活动路由器。如果优先级相同,实际IP高的路由器为活动路由器:
Router(config-if)#glbp group-number priority priority-number
      3.设置Hello和Hold间隔:
Router(config-if)#glbp group-number timers hello-value holdtime-value
      验证配置:
Router#sh glbp interface interface-id
Router#sh glbp brief
三、实验
      实验拓扑:
拓扑
      物理连接:
Router1 S1/0 <----> Router3 S0/0
Router2 S1/0 <----> Router3 S0/1
Router1 F0/0 <----> Switch1 F0/14
Router2 F0/0 <----> Switch1 F0/15
XPC P0/0 <----> Switch1 F0/0 (虚拟机PC1、PC2通过XPC P0/0桥接到交换机上)
VPCS V0/1(PC3) <----> Switch1 F0/1
VPCS V0/2(Server) <----> Router3 F1/0
      地址分配:
GLBP虚拟IP:10.0.0.249/24
R1:
F0/0:10.0.0.253/24
S1/0:200.0.2.1/24
R2:
F0/0:10.0.0.254/24
S1/0:200.0.1.1/24
R3:
S0/0:200.0.2.2/24
S0/1:200.0.1.2/24
F1/0:200.0.0.254/24
Server:
IP:200.0.0.1/24 网关:200.0.0.254/24
PC1:
IP:10.0.0.1/24 网关:10.0.0.200/24
PC2:
IP:10.0.0.2/24 网关:10.0.0.200/24
PC3:
IP:10.0.0.3/24 网关:10.0.0.200/24
      实验目的:
在这个实验中,我们要将R1和R2配置为负载均衡网关。配置完成后用主机访问远端网络,然后打开Windows系统的开始――&gt;运行,使用arp -a来查看网关MAC地址。看看每次是否一样。如果有条件,大家可以用虚拟机来充当PC1和PC2。
     看看配置吧:
路由器R1上的配置:
R1#sh run
Building configuration...
Current configuration : 994 bytes
!
version 12.3
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname R1
!
boot-start-marker
boot-end-marker
!
memory-size iomem 5
no aaa new-model
ip subnet-zero
!
ip cef
!
no ftp-server write-enable
!        
interface FastEthernet0/0
ip address 10.0.0.253 255.255.255.0
duplex auto
speed auto
glbp 1 ip 10.0.0.200
glbp 1 preempt
!
interface Serial1/0
ip address 200.0.2.1 255.255.255.0
serial restart-delay 0
!
interface Serial1/1
no ip address
shutdown
serial restart-delay 0
!
interface Serial1/2
no ip address
shutdown
serial restart-delay 0
!        
interface Serial1/3
no ip address
shutdown
serial restart-delay 0
!
router rip
version 2
network 10.0.0.0
network 200.0.2.0
no auto-summary
!
ip http server
ip classless
!
control-plane
!
line con 0
exec-timeout 0 0
logging synchronous
transport preferred all
transport output all
line aux 0
transport preferred all
transport output all
line vty 0 4
!
end
路由器R2上的配置:
R2#sh run
Building configuration...
Current configuration : 955 bytes
!
version 12.3
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname R2
!
boot-start-marker
boot-end-marker
!
memory-size iomem 5
no aaa new-model
ip subnet-zero
!
ip cef
!
no ftp-server write-enable
!        
interface FastEthernet0/0
ip address 10.0.0.254 255.255.255.0
duplex auto
speed auto
glbp 1 ip 10.0.0.200
glbp 1 preempt
!
interface Serial1/0
ip address 200.0.1.1 255.255.255.0
serial restart-delay 0
!
interface Serial1/1
no ip address
shutdown
serial restart-delay 0
!
interface Serial1/2
no ip address
shutdown
serial restart-delay 0
!        
interface Serial1/3
no ip address
shutdown
serial restart-delay 0
!
router rip
version 2
network 10.0.0.0
network 200.0.1.0
no auto-summary
!
ip http server
ip classless
!
control-plane
!
line con 0
transport preferred all
transport output all
line aux 0
transport preferred all
transport output all
line vty 0 4
!
end
路由器R3上的配置:
R3#sh run
Building configuration...
Current configuration : 965 bytes
!
version 12.3
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname R3
!
boot-start-marker
boot-end-marker
!
!
memory-size iomem 5
no aaa new-model
ip subnet-zero
!
ip cef
!
no ftp-server write-enable
!        
interface Serial0/0
ip address 200.0.2.2 255.255.255.0
serial restart-delay 0
!
interface Serial0/1
ip address 200.0.1.2 255.255.255.0
serial restart-delay 0
!
interface Serial0/2
no ip address
shutdown
serial restart-delay 0
!
interface Serial0/3
no ip address
shutdown
serial restart-delay 0
!
interface FastEthernet1/0
ip address 200.0.0.254 255.255.255.0
duplex auto
speed auto
!
router rip
version 2
network 200.0.0.0
network 200.0.1.0
network 200.0.2.0
no auto-summary
!
ip http server
ip classless
!
control-plane
!
line con 0
transport preferred all
transport output all
line aux 0
transport preferred all
transport output all
line vty 0 4
!
end
      验证一下:
在R1上运行 show glbp brief:
R1BRIEF
在R2上运行 show glbp brief:
R2brief
在R1上运行 show glbp f0/0:
R1#sh glbp f0/0
FastEthernet0/0 - Group 1
  State is Standby
    4 state changes, last state change 00:18:12
  Virtual IP address is 10.0.0.200
  Hello time 3 sec, hold time 10 sec
    Next hello sent in 2.636 secs
  Redirect time 600 sec, forwarder time-out 14400 sec
  Preemption enabled, min delay 0 sec
  Active is 10.0.0.254, priority 100 (expires in 7.760 sec)
  Standby is local
  Priority 100 (default)
  Weighting 100 (default 100), thresholds: lower 1, upper 100
  Load balancing: round-robin
  Group members:
    cc00.04e0.0000 (10.0.0.253) local
    cc00.0654.0000 (10.0.0.254)
  There are 2 forwarders (1 active)
  Forwarder 1
    State is Active
      3 state changes, last state change 00:17:56
    MAC address is 0007.b400.0101 (default)
    Owner ID is cc00.04e0.0000
    Preemption enabled, min delay 30 sec
    Active is local, weighting 100
  Forwarder 2
    State is Listen
    MAC address is 0007.b400.0102 (learnt)
    Owner ID is cc00.0654.0000
    Time to live: 14397.148 sec (maximum 14400 sec)
    Preemption enabled, min delay 30 sec
    Active is 10.0.0.254 (primary), weighting 100 (expires in 7.144 sec)
在R2上运行 show glbp f0/0:
R2#sh glbp f0/0
FastEthernet0/0 - Group 1
  State is Active
    2 state changes, last state change 00:19:32
  Virtual IP address is 10.0.0.200
  Hello time 3 sec, hold time 10 sec
    Next hello sent in 1.144 secs
  Redirect time 600 sec, forwarder time-out 14400 sec
  Preemption enabled, min delay 0 sec
  Active is local
  Standby is 10.0.0.253, priority 100 (expires in 7.148 sec)
  Priority 100 (default)
  Weighting 100 (default 100), thresholds: lower 1, upper 100
  Load balancing: round-robin
  Group members:
    cc00.04e0.0000 (10.0.0.253)
    cc00.0654.0000 (10.0.0.254) local
  There are 2 forwarders (1 active)
  Forwarder 1
    State is Listen
      2 state changes, last state change 00:18:43
    MAC address is 0007.b400.0101 (learnt )
    Owner ID is cc00.04e0.0000
    Redirection enabled, 597.136 sec remaining (maximum 600 sec)
    Time to live: 14399.688 sec (maximum 14400 sec)
    Preemption enabled, min delay 30 sec
    Active is 10.0.0.253 (primary), weighting 100 (expires in 9.684 sec)
    Arp replies sent: 2
  Forwarder 2
    State is Active
      1 state change, last state change 00:21:55
    MAC address is 0007.b400.0102 (default)
    Owner ID is cc00.0654.0000
    Redirection enabled
    Preemption enabled, min delay 30 sec
    Active is local, weighting 100
    Arp replies sent: 1
在主机PC1上Ping远端服务器Server,然后使用ARP -A来查看网关MAC地址。截图如下:
PC1
在主机PC2上Ping远端服务器Server,然后使用arp -a来查看网关MAC地址。截图如下:
PC2 
        通过ARP -A大家看到了,网关的MAC地址通过轮循的方式响应ARP请求的。
        实验就做到这里吧,有问题大家多交流。
        大伙玩的开心!
本文出自 51CTO.COM技术博客

你可能感兴趣的:(职场,休闲,网关负载)