
在SW3上创建VLAN10及VLAN20,将连接PC的端口划入如图所示的VLAN中;
在SW1及SW2上创建VLAN10及VLAN20,同时配置vlanif接口,接口IP如图所示;
在SW1及SW2的vlanif10及vlanif20上分别配置VRRP组,VRRP组的虚拟IP作为对应VLAN的 用户网关。SW1的vlanif10及SW2的vlanif10加入一组VRRP,VRID为10,虚拟IP地址为 192.168.10.254;SW1的vlanif20及SW2的vlanif20加入另一组VRRP,VRID为20,虚拟IP地 址为192.168.20.254。
当网络正常时,SW1为VLAN10的主走设备,SW2为备份;SW2为VLAN20的主走设备,SW1 为备份。任意一台交换机发生故障时,PC1及PC2都能够ping通自己的网关。
接入层交换机SW3的配置如下:
[SW3] vlan batch 10 20
[SW3] interface gigabitEthernet0/0/1
[SW3-GigabitEthernet0/0/1] port link-type access
[SW3-GigabitEthernet0/0/1] port default vlan 10
[SW3] interface gigabitEthernet0/0/2
[SW3-GigabitEthernet0/0/2] port link-type access
[SW3-GigabitEthernet0/0/2] port default vlan 20
……忽略连接终端PC的其他接口的配置
[SW3] interface gigabitEthernet0/0/21
[SW3-GigabitEthernet0/0/21] port link-type trunk
[SW3-GigabitEthernet0/0/21] port trunk allow-pass vlan 10 20
[SW3] interface gigabitEthernet0/0/22
[SW3-GigabitEthernet0/0/22] port link-type trunk
[SW3-GigabitEthernet0/0/22] port trunk allow-pass vlan 10 20 汇聚交换机SW1的配置如下:
汇聚交换机SW2的配置如下:
完成上述配置后,PC1及PC2都能够ping通自己的网关;在正常情况下,SW1的vlanif10是VRRP 组10的Master,由它来响应发到192.168.10.254的ARP请求,同时负责转发VLAN10用户的数据。 SW2的vlanif20是VRRP组20的Master,由它来响应发到192.168.20.254的ARP请求,同时负责转 发VLAN20用户的数据。因此,SW1及SW2对VLAN10及VLAN20的流量进行分担,同时又互为热 备。
在SW2上查看的信息正好相反,SW2为VRRP组10的Backup,又为VRRP组20的Master。
[SW1] vlan batch 10 20
[SW1] interface gigabitEthernet0/0/21
[SW1-GigabitEthernet0/0/21] port link-type trunk
[SW1-GigabitEthernet0/0/21] port trunk allow-pass vlan 10 20
[SW1] interface Vlanif 10
[SW1-vlanif10] ip address 192.168.10.253 24
[SW1-vlanif10] vrrp vrid 10 virtual-ip 192.168.10.254
[SW1-vlanif10] vrrp vrid 10 priority 120
[SW1] interface Vlanif 20
[SW1-vlanif20] ip address 192.168.20.253 24
[SW1-vlanif20] vrrp vrid 20 virtual-ip 192.168.20.254 [SW2] vlan batch 10 20
[SW2] interface gigabitEthernet0/0/22
[SW2-GigabitEthernet0/0/22] port link-type trunk
[SW2-GigabitEthernet0/0/22] port trunk allow-pass vlan 10 20
[SW2] interface Vlanif 10
[SW2-vlanif10] ip address 192.168.10.252 24
[SW2-vlanif10] vrrp vrid 10 virtual-ip 192.168.10.254
[SW2] interface Vlanif 20
[SW2-vlanif20] ip address 192.168.20.252 24
[SW2-vlanif20] vrrp vrid 20 virtual-ip 192.168.20.254
[SW2-vlanif20] vrrp vrid 20 priority 120[SW1]display vrrp
Vlanif10 | Virtual Router 10
State : Master
Virtual IP : 192.168.10.254
Master IP : 192.168.10.253
PriorityRun : 120
PriorityConfig : 120
MasterPriority : 120
Preempt : YES Delay Time : 0 s
TimerRun : 1 s
TimerConfig : 1 s
Auth type : NONE
Virtual MAC : 0000-5e00-010a
Check TTL : YES
Config type : normal-vrrp
Create time : 2016-05-04 15:01:58 UTC-08:00
Last change time : 2016-05-04 15:02:01 UTC-08:00
Vlanif20 | Virtual Router 20
State : Backup
Virtual IP : 192.168.20.254
Master IP : 192.168.20.252
PriorityRun : 100
PriorityConfig : 100
MasterPriority : 120
Preempt : YES Delay Time : 0 s
TimerRun : 1 s
TimerConfig : 1 s
Auth type : NONE
Virtual MAC : 0000-5e00-0114
Check TTL : YES
Config type : normal-vrrp
Create time : 2016-05-04 15:02:12 UTC-08:00
Last change time : 2016-05-04 15:02:54 UTC-08:00
可以使用如下命令查看简化信息:
[SW1]display vrrp brief
VRID State Interface Type Virtual IP ----------------------------------------------------------------
10 Master Vlanif10 Normal 192.168.10.254
20 Backup Vlanif20 Normal 192.168.20.254 ----------------------------------------------------------------
Total:2 Master:1 Backup:1 Non-active:0