三层交换机实现VRRP

三层交换机使用VRRP(热备冗余网关)技术,VRRP(虚拟路由冗余协议)可以保证在双机热备的网络中,不会出现单点故障的情况,能够很好的保护网络数据流通

网络拓扑:

img

三层交换机实现VRRP:

  1. 按拓扑修改主机名,配置IP地址
  2. AR1和LSW 1配置静态路由,LSW2配置默认路由
  3. 创建VLAN,配置VLANif 接口,适当的接口配置成Trunk,适当的接口配置为Access
  4. VRRP备份组1,虚拟IP192.168.1.254/24,LSW1为Master设备,优先级200,LSW2为Backup设备,优先级150
  5. VRRP备份组2,虚拟IP192.168.2.254/24,LSW2为Master设备,优先级200,LSW1为Backup设备,优先级150
  6. 延时配置Master的抢占时间为10秒
  7. 配置VRRP的上行接口跟踪,如果down,降低优先级60
  8. 测试PC1和2.2.2.2的连通性

配置过程:

1.配置链路

LSW1:

vlan batch 10 20 30
int e0/0/1
p l a
p d v 30
inr e0/0/2
p l t
p t a v 10 20

LSW2:

vlan batch 10 20 40
int e0/0/1
p l a
p d v 40
inr e0/0/2
p l t
p t a v 10 20

LSW3:

vlan batch 10 20
int e0/0/1
p l t
p t a v 10 20
int e0/0/2
p l t 
p t a v 10 20

int e0/0/3
p l a
p d v 10
int e0/0/4
p l a
p d v 20

2.配置IP

AR1:

int g0/0/0
ip add 1.1.1.1 30
int g0/0/1
ip add 3.3.3.1 30

int lo0
ip add 2.2.2.2 24

3.配置路由

LSW1:

ip route-static 2.2.2.0 24 1.1.1.1

LSW2:

ip route-static 0.0.0.0 0.0.0.0 3.3.3.1

AR1

ip route-static 192.168.1.0 24 1.1.1.2
ip route-static 192.168.1.0 24 3.3.3.2
ip route-static 192.168.2.0 24 1.1.1.2
ip route-static 192.168.2.0 24 3.3.3.2

4.启用OSPF

LSW1:

ospf
a 0
net 192.168.1.0 0.0.0.255
net 192.168.2.0 0.0.0.255
net 1.1.1.0 0.0.0.3

LSW2:

ospf
a 0
net 192.168.1.0 0.0.0.255
net 192.168.2.0 0.0.0.255
net 3.3.3.0 0.0.0.3

AR1:

ospf 
a 0
net 1.1.1.0 0.0.0.3
net 3.3.3.0 0.0.0.3
net 2.2.2.0 0.0.0.255

5.创建VRRP

LSW1:

int vlan 10
ip add 192.168.1.252 24
vrrp vrid 1 virtual-ip 192.168.1.254
vrrp vrid 1 priority 200
vrrp vrid 1 track interface e0/0/1 reduced 60
vrrp vrid 1 preempt-mode timer delay 10

int vlan 20
ip add 192.168.2.252 24
vrrp vrid 2 virtual-ip 192.168.2.254
vrrp vrid 2 priority 150
vrrp vrid 2 track interface e0/0/1 reduced 60

int vlan 30
ip add 1.1.1.2 30

LSW2:

int vlan 10
ip add 192.168.1.253 24
vrrp vrid 1 virtual-ip 192.168.1.254
vrrp vrid 1 priority 150
vrrp vrid 1 track interface e0/0/1 reduced 60

int vlan 20
vrrp vrid 2 virtual-ip 192.168.2.254 
vrrp vrid 2 priority 200
vrrp vrid 2 track interface e0/0/1 reduced 60
vrrp vrid 2 preempt-mode timer delay 10

int vlan 40
ip add 3.3.3.2 30

6.验证配置

PC1:

PC>ping 2.2.2.2

Ping 2.2.2.2: 32 data bytes, Press Ctrl_C to break
From 2.2.2.2: bytes=32 seq=1 ttl=254 time=156 ms
From 2.2.2.2: bytes=32 seq=2 ttl=254 time=125 ms
From 2.2.2.2: bytes=32 seq=3 ttl=254 time=94 ms
From 2.2.2.2: bytes=32 seq=4 ttl=254 time=141 ms
From 2.2.2.2: bytes=32 seq=5 ttl=254 time=125 ms

--- 2.2.2.2 ping statistics ---
  5 packet(s) transmitted
  5 packet(s) received
  0.00% packet loss
  round-trip min/avg/max = 94/128/156 ms

PC1与2.2.2.2通信正常,散花🎉