【思唯网络学院】CISCO VRRP配置讲解
首页 > >   作者:浙江思唯网络  2019年11月14日 18:07 星期四  字号:   评论:0 条
时间:2019-11-14 18:07   评论:0 条 


CISCO VRRP配置

VRRP

VRRP:虚拟路由器冗余性协议

HSRP不同,可以使用一台路由器的真实IP地址。在VRRP中,有一台主用的(master)路由器,以及一台或者多台的备用(backup)路由器。

CISCO VRRP配置.png

 

VRRP的三种状态

1Initialize

系统启动后进入此状态,当收到接口startup的消息,将转入Backup (优先级不为255时)或Master状态(优先级为255时)。在此状态时,路由器不会对VRRP报文做任何处理。

2Master

当路由器处于Master状态时 它将会做下列工作

*定期发送VRRP组播报文

*发送免费(gratuitousARP报文,以使网络内各主机知道虚拟IP地址所对应的虚拟MAC地址

*响应对虚拟IP地址的ARP请求,并且响应的是虚拟MAC地址,而不是接口真实MAC地址

*转发目的MAC地址为虚拟MAC地址的IP报文

*如果它是这个虚拟IP地址的拥有者,则接收目的IP地址为这个虚拟IP地址的IP报文,否则,丢弃这个IP报文。需要注意的是,由于有这一点要求,所以除非主路由器是IP地址拥有者,否则主机ping虚拟IP地址不能ping通。

Master状态中只有接收到比自己的优先级大的VRRP报文时,才会转为Backup。只有当接收到接口的Shutdown事件时才会转为Initialize

3

当路由器处于Backup状态时 它将会做下列工作:

*接收Master发送的VRRP组播报文 从中了解Master的状态

*对虚拟IP地址的ARP请求 不做响应

*丢弃目的MAC地址为虚拟MAC地址的IP报文

*丢弃目的IP地址为虚拟IP地址的IP报文

只有当Backup接收到MASTER_DOWN这个定时器到时的事件时,才会转为Master 而当接收到比自己的优先级小的VRRP报文时,它只是做丢弃这个报文的处理,从而就不对定时器做重置处理。 这样定时器就会在若干次这样的处理之后到时,于是就转为Master。只有当接收到接口的Shutdown事件时才会转为Initialize

 

VRRP配置

CISCO VRRP配置1.png 

配置vlan10的虚拟网关192.168.10.254,选举sw3master switchsw4backup switch ,并且当sw3的上行链路或者下行链路故障的时候。sw4被选举为master switch

 

预配置

1 sw1:

2 sw1(config)#ip routing

3 sw1(config)#int e0/0

4 sw1(config-if)#no switchport

5 sw1(config-if)#ip addr 12.1.1.1 255.255.255.0

6 sw1(config-if)#no shut

7

8

9

10 sw3:

11 sw3(config)#ip routing

12 sw3(config)#int e0/1

13 sw3(config-if)#no switchport

14 sw3(config-if)#ip addr 12.1.1.2 255.255.255.0

15 sw3(config-if)#no shut

16 sw3(config-if)#int e0/0

17 sw3(config-if)#sw tr en do

18 sw3(config-if)#sw mo tr

19 sw3(config-if)#vlan 10

20 sw3(config-vlan)#int vlan 10

21 sw3(config-if)#ip addr 192.168.10.252 255.255.255.0

22 sw3(config-if)#no shut

23 sw3(config-if)#ex

24

25

26 sw4:

27 sw4(config)#ip routing

28 sw4(config)#int e0/1

29 sw4(config-if)#no sw

30 sw4(config-if)#ip addr 13.1.1.2 255.255.255.0

31 sw4(config-if)#no shut

32 sw4(config-if)#int e0/0

33 sw4(config-if)#sw tr en do

34 sw4(config-if)#sw mo tr

35 sw4(config-if)#int vlan 10

36 sw4(config-if)#ip addr 192.168.10.253 255.255.255.0

37 sw4(config-if)#no shut

38 sw4(config-if)#ex

39

40

41 sw5:

42 sw5(config)#vlan 10

43 sw5(config-vlan)#int vlan 10

44 sw5(config-if)#ip addr 192.168.10.10 255.255.255.0

45 sw5(config-if)#no shut

46 sw5(config-if)#ex

47 sw5(config)#int range e0/1-2

48 sw5(config-if-range)#sw tr en do

49 sw5(config-if-range)#sw mo tr

50 sw5(config-if-range)#int e0/0

51 sw5(config-if)#sw mo acc

52 sw5(config-if)#sw acc vlan 10

53 sw5(config-if)#end

1

————————————————

VRRP配置

1 sw3(VRRP):

2 sw3(confg)#track 1 interface Ethernet0/0 line-protocol # vrrptrack追踪配置是在全局配置模式下配置,再到接口下应用

3 sw3(confg)#track 2 interface Ethernet0/1 line-protocol

4 sw3(config)#int vlan 10

5 sw3(config-if)#vrrp 1 ip 192.168.10.254

6 *Feb 13 13:56:58.014: %VRRP-6-STATECHANGE: Vl10 Grp 1 state Init -> Backup

7 *Feb 13 13:56:58.019: %VRRP-6-STATECHANGE: Vl10 Grp 1 state Init -> Backup

8 sw3(config-if)#vrrp 1

9 *Feb 13 13:57:01.637: %VRRP-6-STATECHANGE: Vl10 Grp 1 state Backup -> Master

10 sw3(config-if)#vrrp 1 priority 200

11 sw3(config-if)#vrrp 1 preempt

12 sw3(config-if)#vrrp 1 track 1 decrement 60 #e0/0口出现故障的时候,sw3的优先级降低60

13 sw3(config-if)#vrrp 1 track 2 decrement 60 #e0/1口出现故障的时候,sw3的优先级降低60

14

15 sw4(VRRP)

16 sw4(confg)#track 1 interface Ethernet0/0 line-protocol

17 sw4(confg)#track 2 interface Ethernet0/1 line-protocol

18 sw4(config)#int vlan 10

19 sw4(config-if)#vrrp 1 ip 192.168.10.254

20 *Feb 13 13:57:42.960: %VRRP-6-STATECHANGE: Vl10 Grp 1 state Init -> Backup

21 *Feb 13 13:57:42.964: %VRRP-6-STATECHANGE: Vl10 Grp 1 state Init -> Backup

22 sw4(config-if)#vrrp 1 priority 150

23 sw4(config-if)#vrrp 1 preempt

24 sw4(config-if)#vrrp 1 track 1 decrement 60 #e0/0口出现故障的时候,sw4的优先级降低60

25 sw4(config-if)#vrrp 1 track 2 decrement 60 #e0/1口出现故障的时候,sw4的优先级降低60

20

验证

1 sw3#show vrrp brief

2 Interface          Grp Pri Time  Own Pre State   Master addr     Group addr

3 Vl10               1   200 3218       Y  Master  192.168.10.252  192.168.10.254

4

5 sw4#show vrrp brief

6 Interface          Grp Pri Time  Own Pre State   Master addr     Group addr

7 Vl10               1   150 3414       Y  Backup  192.168.10.252  192.168.10.254

当上行链路出线故障的时候:

关闭e0/1口,sw3优先级降底60,将被选举为backup router

1 sw3(config)#int e0/1

2 sw3(config-if)#shut

3 sw3(config-if)#

4 *Feb 15 10:58:04.447: %TRACK-6-STATE: 2 interface Et0/1 line-protocol Up -> Down

5 sw3(config-if)#

6 *Feb 15 10:58:06.446: %LINK-5-CHANGED: Interface Ethernet0/1, changed state to administratively down

7 *Feb 15 10:58:07.456: %LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet0/1, changed state to down

8 sw3(config-if)#

9 *Feb 15 10:58:07.495: %VRRP-6-STATECHANGE: Vl10 Grp 1 state Master -> Backup

10 sw3(config-if)#do show vrrp br

11 Interface          Grp Pri Time  Own Pre State   Master addr     Group addr

12 Vl10               1   140 3218       Y  Backup  192.168.10.253  192.168.10.254

13

sw4将被选举为master router

 

1 sw4#

2 *Feb 15 10:58:07.492: %VRRP-6-STATECHANGE: Vl10 Grp 1 state Backup -> Master

3 sw4#show vrrp br

4 Interface          Grp Pri Time  Own Pre State   Master addr     Group addr

5  Vl10 1 150 3414 Y Master 192.168.10.253 192.168.10.254

ICMP测试丢了两个包

 

1 sw5#ping 192.168.10.254 repeat 10000

2 Type escape sequence to abort.

3 Sending 10000, 100-byte ICMP Echos to 192.168.10.254, timeout is 2 seconds:

4 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

5 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

6 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

7 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

8 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

9!!!!!!!..!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

10 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

11 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

12 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

13 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

 当下行链路出线故障的时候:

 关闭e0/1口,sw3优先级降底60,但是由于无法与backup router进行通信,因此sw3还是认为自己是主路由器

 

1 sw3(config-if)#int e0/0

2 sw3(config-if)#shut

3 sw3(config-if)#

4 *Feb 15 11:03:35.989: %TRACK-6-STATE: 1 interface Et0/0 line-protocol Up -> Down

5 sw3(config-if)#

6 *Feb 15 11:03:37.991: %LINK-5-CHANGED: Interface Ethernet0/0, changed state to administratively down

7 *Feb 15 11:03:38.999: %LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet0/0, changed state to down

8 sw3(config-if)#do show vrrp br

9 Interface          Grp Pri Time  Own Pre State   Master addr     Group addr

10 Vl10               1   140 3218       Y  Master  192.168.10.252  192.168.10.254

 

备份路由器在连续三个通告间隔内收不到VRRP或收到优先级为0的通告后启动新的一轮VRRP选举,sw3选举为新的master router

 

1 sw4#

2 *Feb 15 11:03:38.782: %VRRP-6-STATECHANGE: Vl10 Grp 1 state Backup -> Master

3 sw4#show vrrp b

4 Interface          Grp Pri Time  Own Pre State   Master addr     Group addr

5 Vl10               1   150 3414       Y  Master  192.168.10.253  192.168.10.254

6

ICMP测试,ping不通sw3的物理地址,pingsw4的物理地址,ping通虚拟网关地址

 

1 sw5#ping 192.168.10.252

2 Type escape sequence to abort.

3 Sending 5, 100-byte ICMP Echos to 192.168.10.252, timeout is 2 seconds:

4 .....

5 Success rate is 0 percent (0/5)

6 sw5#ping 192.168.10.253

7 Type escape sequence to abort.

8 Sending 5, 100-byte ICMP Echos to 192.168.10.253, timeout is 2 seconds:

9 .!!!!

10 Success rate is 80 percent (4/5), round-trip min/avg/max = 2/2/3 ms

11 sw5#ping 192.168.10.254

12 Type escape sequence to abort.

13 Sending 5, 100-byte ICMP Echos to 192.168.10.254, timeout is 2 seconds:

14 !!!!!

15 Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/1 ms

16 sw5#

17

目前CCIE RS 笔试和LAB 稳定,持续过人中,了解之前的PASS情况和咨询考试情况

 

请加QQ:804990984 , 839898248


技术交流请加群:859273036,备注博客
扫描二维码也可以加群哦:

 

技术交流群.jpg 


 您阅读这篇文章共花了: 
 本文无需标签!
二维码加载中...
技术交流:欢迎在本文下方留言或加入QQ群:859273036 互相学习。     
本文地址:http://www.023wg.com/664.html
版权声明:若无注明,本文皆为“思唯网络学院博客”原创,转载请保留文章出处。

返回顶部    首页   
版权所有:思唯网络学院博客    浙江思唯网络