VRRP負載均衡

 實驗TOP:ide

 

 

實驗說明
這裏用路由器R三、R4模擬兩臺主機
預配置
R1(config)#interface loopback 0
R1(config-if)#ip address 222.9.9.9 255.255.255.0
R1(config-if)#interface fastethernet 0/0
R1(config-if)#ip address 192.168.0.1 255.255.255.0  
R1(config-if)#no shutdown
R2(config)#interface loopback 0
R2(config-if)#ip address 222.9.9.9 255.255.255.0  
R2(config)#interface fastethernet 0/0
R2(config-if)#ip address 192.168.0.2 255.255.255.0
R2(config-if)#no shutdown
R3(config)#no ip routing
R3(config)#interface fastethernet0/0
R3(config-if)#ip address 192.168.0.3 255.255.255.0
R3(config-if)#no shutdown
R3(config-if)#ip default-gateway 192.168.0.100
R4#configure terminal
R4(config)#no ip routing 
R4(config)#ip default-gateway 192.168.0.200
R4(config)#interface fastethernet 0/0
R4(config-if)#ip address 192.168.0.4 255.255.255.0
R4(config-if)#no shutdown
實驗過程
步驟1  在R1上作配置
R1(config)#interface fastethernet 0/0    //進入fastethernet 0/0接口
R1(config-if)#vrrp 100 ip 192.168.0.100   //配置R1上的VRRP組100,虛擬路由器的地址是192.168.0.100
*Mar 30 15:42:37.003: %VRRP-6-STATECHANGE: Fa0/0 Grp 100 state Init -> Backup
*Mar 30 15:42:40.615: %VRRP-6-STATECHANGE: Fa0/0 Grp 100 state Backup -> Master
//這裏咱們能夠發現F0/0接口成爲組100的master路由器,由於如今只有R1上配置了VRRP協議。
R1(config-if)#vrrp 100 priority 150    //配置VRRP組100的優先級爲150
R1(config-if)#vrrp 200 ip 192.168.0.200  //配置R1上的VRRP組200,虛擬路由器的地址是192.168.0.200
*Mar 30 15:43:21.923: %VRRP-6-STATECHANGE: Fa0/0 Grp 200 state Init -> Backup
*Mar 30 15:43:25.535: %VRRP-6-STATECHANGE: Fa0/0 Grp 200 state Backup -> Master
////這裏咱們能夠發現F0/0接口成爲組200的master路由器,由於如今只有R1上配置了VRRP協議。
步驟2  在R2上作配置
R2#configure terminal
R2(config)#interface fastethernet 0/0    //進入接口interface fastethernet 0/0
R2(config-if)#vrrp 100 ip 192.168.0.100   //配置R2上的VRRP組100,虛擬路由器的地址是192.168.0.100
*Mar 30 15:46:24.103: %VRRP-6-STATECHANGE: Fa0/0 Grp 100 state Init -> Backup
//這裏R2的路由器成了備用路由器,由於在組100中它的優先級小於R1的優先級
R2(config-if)#vrrp 200 ip 192.168.0.200   //配置R2上VRRP組200,虛擬路由器的地址是192.168.0.200
*Mar 30 15:46:40.971: %VRRP-6-STATECHANGE: Fa0/0 Grp 200 state Init -> Backup
*Mar 30 15:46:44.583: %VRRP-6-STATECHANGE: Fa0/0 Grp 200 state Backup -> Master
//這裏發現當在R2配置了VRRP組200後,R2路由器成了Master路由器。這是由於在默認狀況下VRRP默認開啓搶佔。
又由於默認狀況下,優先級都是100.在默認狀況下接口IP地址大爲Master路由器。由於R2接口IP大於R1接口IP地址。
因此R2成爲Master路由器。
R2(config-if)#vrrp 200 priority 150  //配置VRRP組200的優先級爲150
步驟3 查看VRRP 
R1#show vrrp   //查看VRRP   
FastEthernet0/0 - Group 100
  State is Master  //R1如今是VRRP組100的 master
  Virtual IP address is 192.168.0.100  //虛擬路由器IP地址爲192.168.0.100
  Virtual MAC address is 0000.5e00.0164  //虛擬路由器的MAC地址是0000.5e00.0164
  Advertisement interval is 1.000 sec      //Master每隔1秒發送一次通告
  Preemption enabled                   //搶佔默認狀況是開啓的
  Priority is 150    //優先級爲150
  Master Router is 192.168.0.1 (local), priority is 150 
  Master Advertisement interval is 1.000 sec
  Master Down interval is 3.414 sec
FastEthernet0/0 - Group 200
  State is Backup  //R1如今是VRRP組200的 master
  Virtual IP address is 192.168.0.200
  Virtual MAC address is 0000.5e00.01c8
  Advertisement interval is 1.000 sec
  Preemption enabled
  Priority is 100 
  Master Router is 192.168.0.2, priority is 150 
  Master Advertisement interval is 1.000 sec
  Master Down interval is 3.609 sec (expires in 2.709 sec)
R1#show vrrp brief  //查看VRRP的詳細信息
Interface          Grp Pri Time  Own Pre State   Master addr     Group addr
Fa0/0              100 150 3414       Y  Master  192.168.0.1     192.168.0.100  
Fa0/0              200 100 3609       Y  Backup  192.168.0.2     192.168.0.200
步驟4  如今同時在R三、R4上準備Ping測試
R3#ping     
Protocol [ip]:     
Target IP address: 222.9.9.9
Repeat count [5]: 10000000
Datagram size [100]: 
Timeout in seconds [2]: 
Extended commands [n]: 
Sweep range of sizes [n]: 
Type escape sequence to abort.
Sending 10000000, 100-byte ICMP Echos to 222.9.9.9, timeout is 2 seconds:
R4#ping
Protocol [ip]: 
Target IP address: 222.9.9.9
Repeat count [5]: 10000000
Datagram size [100]: 
Timeout in seconds [2]: 
Extended commands [n]: 
Sweep range of sizes [n]: 
Type escape sequence to abort.
Sending 10000000, 100-byte ICMP Echos to 222.9.9.9, timeout is 2 seconds:
步驟5 在R1上模擬故障,人爲關掉端口
R1(config)#interface fastethernet0/0
R1(config-if)#shutdown  //關閉端口
步驟6 在R三、R4查看
R3上
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!..!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//這裏的..說明R3上有短暫的中斷,這時的VRRP的Master由R1路由器切換到R2路由器
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
R4上
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
在R1上查看VRRP的運行狀況
R2#show vrrp   //查看VRRP
FastEthernet0/0 - Group 100
  State is Master   //這裏驗證了咱們說的Master由R1切換到了R2
  Virtual IP address is 192.168.0.100
  Virtual MAC address is 0000.5e00.0164
  Advertisement interval is 1.000 sec
  Preemption enabled
  Priority is 100 
  Master Router is 192.168.0.2 (local), priority is 100 
  Master Advertisement interval is 1.000 sec
  Master Down interval is 3.609 sec
當修復故障
R1(config)#interface fastethernet0/0
R1(config-if)#shutdown
R3上
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!.!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//這裏的.說明R3由短暫的中斷,是Master由R2路由切換到R1路由器
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!
說一下,停止PING操做能夠:ctrl+6
相關文章
相關標籤/搜索