VRRP实验
AR1配置
interface GigabitEthernet0/0/0 ip address 192.168.11.1 255.255.255.0 # interface GigabitEthernet0/0/1 ip address 192.168.12.1 255.255.255.0 interface LoopBack0 ip address 100.100.100.100 255.255.255.255 # interface LoopBack1 ip address 200.200.200.200 255.255.255.255 # ospf 1 router-id 1.1.1.1 area 0.0.0.0 network 100.100.100.100 0.0.0.0 network 192.168.11.0 0.0.0.255 network 192.168.12.0 0.0.0.255 network 200.200.200.200 0.0.0.0
SW1配置
vlan batch 10 20 interface Vlanif1 ip address 192.168.11.2 255.255.255.0 # interface Vlanif10 ip address 192.168.10.252 255.255.255.0 vrrp vrid 10 virtual-ip 192.168.10.1 配置虚拟网关 vrrp vrid 10 priority 120 vrrp vrid 10 track interface GigabitEthernet0/0/1 reduced 30 g0/0/1是条上行接口,用来做链路跟踪,当上行链路断开的时候避免数据包还要从原来的设备上转发数据包,
reduced 30当上行链路断开后,优先级降低30.
vrrp vrid 10 authentication-mode md5 jk7^<D5NF#'eKRQqbl+O`aW#
# interface Vlanif20 ip address 192.168.20.252 255.255.255.0 vrrp vrid 20 virtual-ip 192.168.20.1
vrrp vrid 20 authentication-mode md5 H'z&USe)y-o\lT0$,T(B1cq#
interface GigabitEthernet0/0/2 port link-type trunk port trunk allow-pass vlan 2 to 4094 # interface GigabitEthernet0/0/3 port link-type trunk undo port trunk allow-pass vlan 1 port trunk allow-pass vlan 2 to 4094
ospf 1 router-id 2.2.2.2
import-route direct
area 0.0.0.0
network 192.168.11.2 0.0.0.0
SW2配置
vlan batch 10 20 interface Vlanif1 ip address 192.168.12.2 255.255.255.0 # interface Vlanif10 ip address 192.168.10.253 255.255.255.0 vrrp vrid 10 virtual-ip 192.168.10.1
vrrp vrid 10 authentication-mode md5 jk7^<D5NF#'eKRQqbl+O`aW#
# interface Vlanif20 ip address 192.168.20.253 255.255.255.0 vrrp vrid 20 virtual-ip 192.168.20.1 vrrp vrid 20 priority 120 vrrp vrid 20 track interface GigabitEthernet0/0/1 reduced 30
vrrp vrid 20 authentication-mode md5 H'z&USe)y-o\lT0$,T(B1cq#
interface GigabitEthernet0/0/2 port link-type trunk port trunk allow-pass vlan 2 to 4094 # interface GigabitEthernet0/0/3 port link-type trunk port trunk allow-pass vlan 2 to 4094 ospf 1 router-id 3.3.3.3 import-route direct area 0.0.0.0 network 192.168.12.2 0.0.0.0
SW3配置
vlan batch 10 20 interface GigabitEthernet0/0/1 port link-type trunk port trunk allow-pass vlan 2 to 4094 # interface GigabitEthernet0/0/2 port link-type trunk port trunk allow-pass vlan 2 to 4094 # interface GigabitEthernet0/0/3 port link-type access port default vlan 10 # interface GigabitEthernet0/0/4 port link-type access port default vlan 20
PC配置
<SW1> dis vrrp brief VRID State Interface Type Virtual IP ---------------------------------------------------------------- 10 Master Vlanif10 Normal 192.168.10.1 20 Backup Vlanif20 Normal 192.168.20.1 ---------------------------------------------------------------- Total:2 Master:1 Backup:1 Non-active:0 <SW1>
1 当交换机 lsw1和 lsw2作何一个断电或重启后,VLAN10 和 VLAN20 的主机和外网100.100.100.100的通信不会中断 (中间有短暂丢包) 2 当交换机 lsw1和 lsw2的任何一个上行链路关闭后,VLAN10 和 VLAN20 的主机和外网100.100.100.100的通信不会 中断(中间有短暂丢包) 3 当网络一切正常后,VLAN10 和 VLAN20 去网外的流量可以在 lsw1 和 lsw2上负载分担。