VRRP协议(ip网络基础实验08)

本文档详述了一项网络实验,涉及VRRP(虚拟路由冗余协议)的配置,包括路由器接口IP地址设置、RIP路由协议配置、VRRP主用和备用路由器的设定,以及虚拟网关的建立。实验结果显示,无论是在单一主用路由器还是虚拟网关的负载均衡情况下,全网都能正常通信。当主用路由器故障时,通过Wireshark抓包分析验证了VRRP的切换机制。
摘要由CSDN通过智能技术生成

实验拓扑图:
在这里插入图片描述

一、前言

1.相关术语

在这里插入图片描述

2.工作机制

在这里插入图片描述

二、实验步骤

1.进行网段地划分和IP地址的规划

靠下一侧为.1,靠上一侧为.2

2.为PC机配置IP地址及网关

PC1>ip 1.1.1.2/24 1.1.1.1
PC2>ip 192.168.1.200/24 192.168.1.3
主机IP地址子网掩码网关
PC11.1.1.2255.255.255.01.1.1.1
PC2192.168.1.200255.255.255.0192.168.1.3(虚拟网关)

3.先为路由器做基本配置

1)为路由器接口配置IP地址,并打开接口(no shut)

以R1为例,R2、R3同理。

R1(config-if)#ip addr 1.1.1.1 255.255.255.0
R1(config-if)#no shut(打开接口)
R1(config-if)#exit
R1(config)#int f1/0(为接口f1/0配置IP地址)
R1(config-if)#ip addr 192.168.14.2 255.255.255.0
R1(config-if)#no shut(打开接口)
R1(config-if)#exit
R1(config)#int f1/1(为接口f1/1配置IP地址)
R1(config-if)#ip addr 192.168.24.2 255.255.255.0
R1(config-if)#no shut(打开接口)
R1(config-if)#exit

路由器接口状态展示:

路由器接口IP地址掩码
R1f0/01.1.1.1255.255.255.0
R1f1/0192.168.14.2255.255.255.0
R1f1/1192.168.24.2255.255.255.0
R2f0/0192.168.1.1255.255.255.0
R2f1/0192.168.14.1255.255.255.0
R3f0/0192.168.1.2255.255.255.0
R3f1/1192.168.24.1255.255.255.0

2)配置路由协议

可以是动态路由(配置所有直连网段),
也可以是静态路由(配置所有非直连网段)

下面为路由器配置动态路由,以R1为例,R2、R3同理。

R1#config t
Enter configuration commands, one per line.  End with CNTL/Z.
R1(config)#router rip(开启RIP配置)
R1(config-router)#version 2(启用RIP版本2R1(config-router)#no auto-summary(禁用自动汇总)
R1(config-router)#network 1.1.1.0(配置RIP)
R1(config-router)#network 192.168.14.0
R1(config-router)#network 192.168.24.0

3)将switch与路由器相连的接口改为dot1q类型

在这里插入图片描述

4.下面配置两种情况

情况1:
R2为主用路由器,R3为备用路由器
==> vrrp 1 IP地址即为 R2 f0/0接口 IP地址;vrrp 2 IP地址即为 R3 f0/0接口 IP地址(可不配置)

情况2:
R2,R3数据共同传输,一方忙时通过另一方传输
==> vrrp 1 IP地址都为虚拟网关地址。

5.情况1:R1主用,R2备用

需将pc2的网关IP改为192.168.1.1

PC2> ip 192.168.1.200/24 192.168.1.1
Checking for duplicate address...
PC1 : 192.168.1.200 255.255.255.0 gateway 192.168.1.1

PC2> save
Saving startup configuration to startup.vpc
.  done
R2#config t
Enter configuration commands, one per line.  End with CNTL/Z.
R2(config)#int f0/0
R2(config-if)#vrrp 1 ip 192.168.1.1
R2(config-if)#vrrp 2 ip 192.168.1.2
R2#show vrrp
FastEthernet0/0 - Group 1
  State is Master
  Virtual IP address is 192.168.1.1
  Virtual MAC address is 0000.5e00.0101
  Advertisement interval is 1.000 sec
  Preemption enabled
  Priority is 255
  Master Router is 192.168.1.1 (local), priority is 255
  Master Advertisement interval is 1.000 sec
  Master Down interval is 3.003 sec

FastEthernet0/0 - Group 2
  State is Master
  Virtual IP address is 192.168.1.2
  Virtual MAC address is 0000.5e00.0102
  Advertisement interval is 1.000 sec
  Preemption enabled
  Priority is 100
  Master Router is 192.168.1.1 (local), priority is 100
  Master Advertisement interval is 1.000 sec
  Master Down interval is 3.609 sec
R3#config t
Enter configuration commands, one per line.  End with CNTL/Z.
R3(config)#int f0/0
R3(config-if)#vrrp 1 ip 192.168.1.1
R3(config-if)#vrrp 2 ip 192.168.1.2
R3#show vrrp
FastEthernet0/0 - Group 1
  State is Backup
  Virtual IP address is 192.168.1.1
  Virtual MAC address is 0000.5e00.0101
  Advertisement interval is 1.000 sec
  Preemption enabled
  Priority is 100
  Master Router is 192.168.1.1, priority is 255
  Master Advertisement interval is 1.000 sec
  Master Down interval is 3.609 sec (expires in 3.073 sec)

FastEthernet0/0 - Group 2
  State is Master
  Virtual IP address is 192.168.1.2
  Virtual MAC address is 0000.5e00.0102
  Advertisement interval is 1.000 sec
  Preemption enabled
  Priority is 255
  Master Router is 192.168.1.2 (local), priority is 255
  Master Advertisement interval is 1.000 sec
  Master Down interval is 3.003 sec

保存配置,举例:

R2#write
Building configuration...
[OK]
PC2> save
Saving startup configuration to startup.vpc
.  done

6.情况1:测试

PC2> ping 192.168.14.1
84 bytes from 192.168.14.1 icmp_seq=1 ttl=255 time=9.638 ms
84 bytes from 192.168.14.1 icmp_seq=2 ttl=255 time=11.289 ms
84 bytes from 192.168.14.1 icmp_seq=3 ttl=255 time=10.315 ms
84 bytes from 192.168.14.1 icmp_seq=4 ttl=255 time=6.850 ms
84 bytes from 192.168.14.1 icmp_seq=5 ttl=255 time=7.108 ms
PC2> ping 192.168.14.2
192.168.14.2 icmp_seq=1 timeout
84 bytes from 192.168.14.2 icmp_seq=2 ttl=254 time=37.356 ms
84 bytes from 192.168.14.2 icmp_seq=3 ttl=254 time=27.576 ms
84 bytes from 192.168.14.2 icmp_seq=4 ttl=254 time=34.110 ms
84 bytes from 192.168.14.2 icmp_seq=5 ttl=254 time=27.610 ms
PC2> ping 1.1.1.2
1.1.1.2 icmp_seq=1 timeout
84 bytes from 1.1.1.2 icmp_seq=2 ttl=62 time=54.204 ms
84 bytes from 1.1.1.2 icmp_seq=3 ttl=62 time=38.891 ms
84 bytes from 1.1.1.2 icmp_seq=4 ttl=62 time=39.075 ms
84 bytes from 1.1.1.2 icmp_seq=5 ttl=62 time=43.174 ms

7.情况2:虚拟网关192.168.1.3

R2#config t
R2(config)#int f0/0
R2(config-if)#vrrp 1 ip 192.168.1.3
R3#config t
R3(config)#int f0/0
R3(config-if)#vrrp 1 ip 192.168.1.3
R2#show vrrp
FastEthernet0/0 - Group 1
  State is Backup
  Virtual IP address is 192.168.1.3
  Virtual MAC address is 0000.5e00.0101
  Advertisement interval is 1.000 sec
  Preemption enabled
  Priority is 100
  Master Router is 192.168.1.2, priority is 100
  Master Advertisement interval is 1.000 sec
  Master Down interval is 3.609 sec (expires in 2.641 sec)
R3#show vrrp
FastEthernet0/0 - Group 1
  State is Master
  Virtual IP address is 192.168.1.3
  Virtual MAC address is 0000.5e00.0101
  Advertisement interval is 1.000 sec
  Preemption enabled
  Priority is 100
  Master Router is 192.168.1.2 (local), priority is 100
  Master Advertisement interval is 1.000 sec
  Master Down interval is 3.609 sec

8.情况2:测试

PC2> ping 192.168.24.1
84 bytes from 192.168.24.1 icmp_seq=1 ttl=255 time=7.179 ms
84 bytes from 192.168.24.1 icmp_seq=2 ttl=255 time=13.763 ms
84 bytes from 192.168.24.1 icmp_seq=3 ttl=255 time=4.590 ms
84 bytes from 192.168.24.1 icmp_seq=4 ttl=255 time=7.372 ms
84 bytes from 192.168.24.1 icmp_seq=5 ttl=255 time=4.653 ms

PC2> ping 192.168.24.2
84 bytes from 192.168.24.2 icmp_seq=1 ttl=254 time=28.679 ms
84 bytes from 192.168.24.2 icmp_seq=2 ttl=254 time=30.906 ms
84 bytes from 192.168.24.2 icmp_seq=3 ttl=254 time=26.973 ms
84 bytes from 192.168.24.2 icmp_seq=4 ttl=254 time=20.812 ms
84 bytes from 192.168.24.2 icmp_seq=5 ttl=254 time=25.170 ms

PC2> ping 1.1.1.2
1.1.1.2 icmp_seq=1 timeout
84 bytes from 1.1.1.2 icmp_seq=2 ttl=62 time=30.579 ms
84 bytes from 1.1.1.2 icmp_seq=3 ttl=62 time=47.245 ms
84 bytes from 1.1.1.2 icmp_seq=4 ttl=62 time=51.657 ms
84 bytes from 1.1.1.2 icmp_seq=5 ttl=62 time=46.760 ms

三、实验结果

两种情况下全网都可以通信(ping通)

情况2:将R2的f0/0接口down掉,使用Wireshark进行抓包(vrrp)并分析。

R2#config t
R2(config)#int f0/0
R2(config-if)#shutdown(关闭接口)

在这里插入图片描述
在Wireshark中进行抓包,启用vrrp显示过滤器
在这里插入图片描述
截取报文进行分析
在这里插入图片描述
可以看到IP地址为192.168.1.2(转换路径成功)

四、思考与总结

1.在一个VRRP组中,如何指定其中的一台设备为主用设备?假如故障的主用设备恢复,是否执行切换动作?

比较优先级的大小,优先级高者当选为Master设备。当两台设备优先级相同时,如果已经存在Master,则其保持Master身份,无需继续选举;如果不存在Master,则继续比较接口IP地址大小,接口IP地址较大的设备当选为Master设备。不执行切换动作。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

HAL9000pp

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值