实验TOP:
实验说明
这里用路由器R3、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 现在同时在R3、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 在R3、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