Skip to main content


【思科】VRRP热备路由协议实验

2014-08-25 01:48 浏览:

实验拓扑:

wKiom1P4gcKRSpTrAAEHx2_Vih4132.jpg

 

实验需求:

  1. 假设R3路由器为外网路由器,上面有一条虚拟网段3.3.3.0,模拟外网。

  2. C1为vlan10 ,C2为vlan 20。

  3. R1作为vlan10的主路由器,vlan20的备用路由器。R2作为vlan10的备用路由器,vlan10的主路由器。

  4. 测试热备路由的效果。

 

实验步骤:

  1. 配置C1,C2的IP地址,配置交换机R4

 

R4#conf t

Enter configuration commands, one per line.  End with CNTL/Z.

R4(config)#no ip routing

R4(config)#vlan 10,20

R4(config-vlan)#ex

R4(config)#int f1/1

R4(config-if)#switchport access vlan 10

R4(config-if)#int f1/2                 

R4(config-if)#switchport access vlan 20

R4(config-if)#int f1/3                 

R4(config-if)#int range f1/3 -4

R4(config-if-range)#switchport mode trunk 

R4(config-if-range)#

*Mar  1 00:04:35.099: %DTP-5-TRUNKPORTON: Port Fa1/3-4 has become dot1q trunk

 

2.配置R1

R1#conf t

Enter configuration commands, one per line.  End with CNTL/Z.

R1(config)#ip routing                   //开启路由

R1(config)#int f1/4

R1(config-if)#no sh

R1(config-if)#switchport mode trunk 

R1(config-if)#

*Mar  1 00:05:45.635: %DTP-5-TRUNKPORTON: Port Fa1/4 has become dot1q trunk

R1(config)#track 1 int f1/3 line-protocol                  

R1(config-track)#track 2 int f1/4 line-protocol            //创建监听端口

R1(config)#vlan 10

R1(config-vlan)#vlan 20    

R1(config-vlan)#ex

 

(1)配置vlan 10

R1(config)#int vlan 10

R1(config-if)#ip add 192.168.10.10 255.255.255.0

R1(config-if)#no sh

R1(config-if)#ex  

*Mar  1 00:07:54.263: %LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan10, changed state to up

R1(config-vlan)#ex

R1(config)#int vlan 10

R1(config-if)#vrrp 1 ?

  authentication  Authentication

  description     Group specific description

  ip              Enable Virtual Router Redundancy Protocol (VRRP) for IP

  preempt         Enable preemption of lower priority Master

  priority        Priority of this VRRP group

  shutdown        Disable VRRP Configuration

  timers          Set the VRRP timers

  track           Event Tracking

 

R1(config-if)#vrrp 1 ip 192.168.10.1         //虚拟网关IP

*Mar  1 00:09:20.763: %VRRP-6-STATECHANGE: Vl10 Grp 1 state Init -> Backup        

*Mar  1 00:09:24.375: %VRRP-6-STATECHANGE: Vl10 Grp 1 state Backup -> Master

R1(config-if)#vrrp 1 preempt                  //设置抢占

R1(config-if)#vrrp 1 priority 100             //设置优先级,主要高于备用优先级

R1(config-if)#vrrp 1 track 1                  //设置监听端口

R1(config-if)#vrrp 1 track 2

 

(2)配置vlan 20

R1(config)#int vlan 20  

*Mar  1 00:10:39.051: %LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan20, changed state to up

R1(config-if)#ip add 192.168.20.10 255.255.255.0

R1(config-if)#no sh

R1(config-if)#vrrp 2 ip 192.168.20.1              

*Mar  1 00:11:02.399: %VRRP-6-STATECHANGE: Vl20 Grp 2 state Init -> Backup     

R1(config-if)#vrrp 2 preempt 

*Mar  1 00:11:06.007: %VRRP-6-STATECHANGE: Vl20 Grp 2 state Backup -> Master  

R1(config-if)#vrrp 2 priority 95              //要低于主路由器的优先级

*Mar  1 00:12:58.911: %VRRP-6-STATECHANGE: Vl10 Grp 1 state Master -> Backup

*Mar  1 00:13:09.515: %VRRP-6-STATECHANGE: Vl10 Grp 1 state Backup -> Master

*Mar  1 00:13:47.295: %VRRP-6-STATECHANGE: Vl20 Grp 2 state Master -> Backup

 

3.配置R2

R2#conf t

Enter configuration commands, one per line.  End with CNTL/Z.

R2(config)#ip routing

R2(config)#int f1/4

R2(config-if)#no sh

R2(config-if)#switchport mode trunk 

R2(config-if)#

*Mar  1 00:10:09.595: %DTP-5-TRUNKPORTON: Port Fa1/4 has become dot1q trunk

R2(config-if)#ex

R1(config)#track 1 int f1/3 line-protocol 

R1(config-track)#track 2 int f1/4 line-protocol

R2(config)#vlan 10

R2(config-vlan)#vlan 20

 

(1)配置vlan 10

R2(config-vlan)#int vlan 10

*Mar  1 00:10:20.911: %LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan10, changed state to up

R2(config-if)#ip add 192.168.10.20 255.255.255.0

R2(config-if)#no sh

R2(config-if)#vrrp 1 ip 192.168.10.1     

*Mar  1 00:12:54.007: %VRRP-6-STATECHANGE: Vl10 Grp 1 state Init -> Backup

R2(config-if)#vrrp 1 preempt 

*Mar  1 00:12:57.619: %VRRP-6-STATECHANGE: Vl10 Grp 1 state Backup -> Master    

R2(config-if)#vrrp 1 priority 95

R2(config-if)#ex

R2(config)#

 

(2)配置vlan 20

R2(config)#int vlan 20

*Mar  1 00:13:14.543: %LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan20, changed state to up

R2(config-if)#ip add 192.168.20.20 255.255.255.0

R2(config-if)#no sh

R2(config-if)#vrrp 2 ip 192.168.20.1         

*Mar  1 00:13:42.375: %VRRP-6-STATECHANGE: Vl20 Grp 2 state Init -> Backup

R2(config-if)#vrrp 2 preempt 

*Mar  1 00:13:45.983: %VRRP-6-STATECHANGE: Vl20 Grp 2 state Backup -> Master    

R2(config-if)#vrrp 2 priority 100

R2(config-if)#vrrp 2 track 1

R2(config-if)#vrrp 2 track 2

R2(config-if)#ex

 

4.分别在R1,R2上检查一下vrrp的配置是否正确

R1#show vrrp b

Interface          Grp Pri Time  Own Pre State   Master addr     Group addr

Vl10               1   100 3609       Y  Master  192.168.10.10   192.168.10.1   

Vl20               2   95  3628       Y  Backup  192.168.20.20   192.168.20.1 

 

R2#show vrrp b

Interface          Grp Pri Time  Own Pre State   Master addr     Group addr

Vl10               1   95  3628       Y  Backup  192.168.10.10   192.168.10.1   

Vl20               2   100 3609       Y  Master  192.168.20.20   192.168.20.1

 

无误,分别配置上行口IP

R1(config)#int f1/3

R1(config-if)#no switchport                              将二层口变为三层口

R1(config-if)#ip add 13.0.0.1 255.255.255.0

R1(config-if)#no sh

R1(config-if)#

*Mar  1 00:14:36.199: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet1/3, changed state to up

R1(config-if)#ex

 

R2(config)#int f1/3

R2(config-if)#no switchport  

*Mar  1 00:14:50.827: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet1/3, changed state to up

R2(config-if)#ip add 23.0.0.2 255.255.255.0

R2(config-if)#no sh

R2(config-if)#ex

 

配置外网路由器R3

R3#conf t

Enter configuration commands, one per line.  End with CNTL/Z.

R3(config)#int f0/0

R3(config-if)#ip add 13.0.0.3 255.255.255.0

R3(config-if)#no sh

R3(config-if)#int f0/1                     

*Mar  1 00:15:18.651: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up

*Mar  1 00:15:19.651: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up

R3(config-if)#ip add 23.0.0.3 255.255.255.0

R3(config-if)#no sh

*Mar  1 00:15:32.571: %LINK-3-UPDOWN: Interface FastEthernet0/1, changed state to up

*Mar  1 00:15:33.571: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up

R3(config)#int l0                           //建立虚拟接口

*Mar  1 00:15:36.259: %LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback0, changed state to up.

R3(config-if)#ip add 3.3.3.3 255.255.255.0

R3(config-if)#no sh

R3(config-if)#ex

 

5.使用动态协议RIP互相告知网段

R3(config)#router rip                          //启动RIP协议

R3(config-router)#network 3.3.3.0              //告知与自己直连网段,以便相邻路由器学习

R3(config-router)#network 13.0.0.0

R3(config-router)#network 23.0.0.0

 

R1(config)#router rip 

R1(config-router)#network 13.0.0.0

R1(config-router)#network 192.168.10.0

R1(config-router)#network 192.168.20.0

 

R2(config)#router rip

R2(config-router)#network 23.0.0.0

R2(config-router)#network 192.168.10.0

R2(config-router)#network 192.168.20.0

 

6.可以连通测试了
 

wKiom1P4jX2zX-caAAEEDhfmCbg291.jpg
 

可以发现,C1走的路线是R1,C2走的路线是R2。这是刚才配置的vrrp优先级决定的。

将R1的上行口f1/3 和 R3的f0/0口 shutdown,观察tracert的变化。
 

wKioL1P4j0OyCnJkAAB8aqT2Nis240.jpg
 

此时R1已经的不同,电脑C1的路线已经由R1切换到了R2。再将R1的f1/3口和R3的f0/0口 no shutdown,观察变化
 

wKiom1P4jqXzeYbgAABq6XFYVxs911.jpg
 

可以发现R1又将C1的路线抢占过来了。这样,热备路由的目的已经实现。

C2同理。

相关文章

cisco 2960如何保存配置到本地,适用其他思科路由

2014-06-29 01:09:49    浏览: 184

思科默认路由以及浮动路由

2014-04-26 23:36:01    浏览: 163

用思科做HSRP

2014-02-23 00:13:56    浏览: 194

配置思科的日志系统

2013-11-23 01:17:16    浏览: 194

思科路由器端口汇聚配置

2013-11-05 00:04:40    浏览: 80