# 设置监视接口。
[SwitchA-Vlan-interface2] vrrp vrid 1 track interface vlan-interface 3 reduced 30
(2) 配置Switch B # 配置VLAN2。
[SwitchB-vlan2] port ethernet 1/0/5 [SwitchB-vlan2] quit
[SwitchB] interface vlan-interface 2
[SwitchB-Vlan-interface2] ip address 202.38.160.2 255.255.255.0
# 创建备份组1,并配置备份组1的虚拟IP地址为202.38.160.111。
[SwitchB-Vlan-interface2] vrrp vrid 1 virtual-ip 202.38.160.111
# 设置备份组的认证方式为SIMPLE认证,认证字为hello。
[SwitchB-Vlan-interface2] vrrp vrid 1 authentication-mode simple hello
# 设置Master发送VRRP报文的间隔时间为5秒。
[SwitchB-Vlan-interface2] vrrp vrid 1 timer advertise 5
(3) 验证配置结果
配置完成后,在Host A上可以ping通Host B。通过display vrrp verbose命令查看配置后的结果。
# 显示Switch A上备份组1的详细信息。
[SwitchA-Vlan-interface2] display vrrp verbose IPv4 Standby Information: Run Method : VIRTUAL-MAC
Total number of virtual routers: 1 Interface : Vlan-interface2
VRID : 1 Adver. Timer : 5
Admin Status : UP State : Master Config Pri : 110 Run Pri : 110 Preempt Mode : YES Delay Time : 0
Auth Type : SIMPLE TEXT Key : hello Track IF : Vlan3 Pri Reduced : 30 Virtual IP : 202.38.160.111 Virtual MAC : 0000-5e00-0101 Master IP : 202.38.160.1
# 显示Switch B上备份组1的详细信息。
[SwitchB-Vlan-interface2] display vrrp verbose IPv4 Standby Information: Run Method : VIRTUAL-MAC
Total number of virtual routers: 1 Interface : Vlan-interface2
VRID : 1 Adver. Timer : 5
Admin Status : UP State : Backup Config Pri : 100 Run Pri : 100 Preempt Mode : YES Delay Time : 0
Auth Type : SIMPLE TEXT Key : hello Virtual IP : 202.38.160.111 Master IP : 202.38.160.1
以上显示信息表示在备份组1中Switch A为Master路由器,Switch B为Backup路由器,Host A发送给Host B的报文通过Switch A转发。
Switch A连接Internet的VLAN接口3不可用时,在Host A上仍然可以ping通Host B。通过display vrrp verbose命令查看备份组的信息。
# Switch A的VLAN接口3不可用时,显示Switch A上备份组1的详细信息。
[SwitchA-Vlan-interface2] display vrrp verbose IPv4 Standby Information: Run Method : VIRTUAL-MAC
Total number of virtual routers: 1 Interface : Vlan-interface2
VRID : 1 Adver. Timer : 5
Admin Status : UP State : Backup Config Pri : 110 Run Pri : 80 Preempt Mode : YES Delay Time : 0
Auth Type : SIMPLE TEXT Key : hello Track IF : Vlan3 Pri Reduced : 30 Virtual IP : 202.38.160.111 Master IP : 202.38.160.2
# Switch A的VLAN接口3不可用时,显示Switch B上备份组1的详细信息。
[SwitchB-Vlan-interface2] display vrrp verbose IPv4 Standby Information: Run Method : VIRTUAL-MAC
Total number of virtual routers: 1 Interface : Vlan-interface2
VRID : 1 Adver. Timer : 5
Admin Status : UP State : Master Config Pri : 100 Run Pri : 100 Preempt Mode : YES Delay Time : 0
Auth Type : SIMPLE TEXT Key : hello Virtual IP : 202.38.160.111 Virtual MAC : 0000-5e00-0101 Master IP : 202.38.160.2
以上显示信息表示Switch A的VLAN接口3不可用时,Switch A的优先级降低为80,成为Backup路由器,Switch B成为Master路由器,Host A发送给Host B的报文通过Switch B转发。
1.4.3 VRRP多备份组配置举例
1. 组网需求
VLAN 2内主机的缺省网关为202.38.160.100/25;VLAN 3内主机的缺省网关为
202.38.160.200/25;
Switch A和Switch B同时属于虚拟IP地址为202.38.160.100/25的备份组1和虚拟
IP地址为202.38.160.200/25的备份组2;
在备份组1中Switch A的优先级高于Switch B,在备份组2中Switch B的优先级高
于Switch A,从而保证VLAN 2和VLAN 3内的主机分别通过Switch A和Switch B通信,当Switch A或Switch B出现故障时,主机可以通过另一台设备继续通信,避免通信中断。
2. 组网图
图1-9 VRRP多备份组配置组网图
Virtual IP address 1: 202.38.160.100/25VLAN 2Gateway:202.38.160.100/25Vlan-int2202.38.160.1/25Vlan-int3202.38.160.130/25Switch AInternetVLAN 3Gateway:202.38.160.200/25Vlan-int2202.38.160.2/25Vlan-int3202.38.160.131/25Switch BVirtual IP address 2: 202.38.160.200/25
3. 配置步骤 (1) 配置Switch A # 配置VLAN 2。
[SwitchA-vlan2] port ethernet 1/0/5 [SwitchA-vlan2] quit
[SwitchA] interface vlan-interface 2
[SwitchA-Vlan-interface2] ip address 202.38.160.1 255.255.255.128
# 创建备份组1,并配置备份组1的虚拟IP地址为202.38.160.100。
[SwitchA-Vlan-interface2] vrrp vrid 1 virtual-ip 202.38.160.100
# 设置Switch A在备份组1中的优先级为110。
[SwitchA-Vlan-interface2] vrrp vrid 1 priority 110 [SwitchA-Vlan-interface2] quit
# 配置VLAN 3。
[SwitchA] vlan 3
[SwitchA-vlan3] port ethernet 1/0/6 [SwitchA-vlan3] quit
[SwitchA] interface vlan-interface 3
[SwitchA-Vlan-interface3] ip address 202.38.160.130 255.255.255.128
# 创建备份组2,并配置备份组2的虚拟IP地址为202.38.160.200。
[SwitchA-Vlan-interface3] vrrp vrid 2 virtual-ip 202.38.160.200
(2) 配置Switch B # 配置VLAN 2。
[SwitchB-vlan2] port ethernet 1/0/5 [SwitchB-vlan2] quit
[SwitchB] interface vlan-interface 2
[SwitchB-Vlan-interface2] ip address 202.38.160.2 255.255.255.128
# 创建备份组1,并配置备份组1的虚拟IP地址为202.38.160.100。
[SwitchB-Vlan-interface2] vrrp vrid 1 virtual-ip 202.38.160.100 [SwitchB-Vlan-interface2] quit
# 配置VLAN 3。
[SwitchB] vlan 3
[SwitchB-vlan3] port ethernet 1/0/6 [SwitchB-vlan3] quit
[SwitchB] interface vlan-interface 3
[SwitchB-Vlan-interface3] ip address 202.38.160.131 255.255.255.128
# 创建备份组2,并配置备份组2的虚拟IP地址为202.38.160.200。
[SwitchB-Vlan-interface3] vrrp vrid 2 virtual-ip 202.38.160.200
# 设置Switch B在备份组2中的优先级为110。
[SwitchB-Vlan-interface3] vrrp vrid 2 priority 110
(3) 验证配置结果
可以通过display vrrp verbose命令查看配置后的结果。 # 显示Switch A上备份组的详细信息。
[SwitchA-Vlan-interface3] display vrrp verbose IPv4 Standby Information: Run Method : VIRTUAL-MAC
Total number of virtual routers: 2 Interface : Vlan-interface2
VRID : 1 Adver. Timer : 1
Admin Status : UP State : Master Config Pri : 110 Run Pri : 110 Preempt Mode : YES Delay Time : 0 Auth Type : NONE
Virtual IP : 202.38.160.100 Virtual MAC : 0000-5e00-0101 Master IP : 202.38.160.1
Interface : Vlan-interface3
VRID : 2 Adver. Timer : 1
Admin Status : UP State : Backup Config Pri : 100 Run Pri : 100 Preempt Mode : YES Delay Time : 0 Auth Type : NONE
Virtual IP : 202.38.160.200 Master IP : 202.38.160.131
# 显示Switch B上备份组的详细信息。
[SwitchB-Vlan-interface3] display vrrp verbose IPv4 Standby Information: Run Method : VIRTUAL-MAC
Total number of virtual routers: 2 Interface : Vlan-interface2
VRID : 1 Adver. Timer : 1
Admin Status : UP State : Backup Config Pri : 100 Run Pri : 100 Preempt Mode : YES Delay Time : 0 Auth Type : NONE
Virtual IP : 202.38.160.100 Master IP : 202.38.160.1
Interface : Vlan-interface3
VRID : 2 Adver. Timer : 1
Admin Status : UP State : Master Config Pri : 110 Run Pri : 110 Preempt Mode : YES Delay Time : 0 Auth Type : NONE
Virtual IP : 202.38.160.200 Virtual MAC : 0000-5e00-0102 Master IP : 202.38.160.131
以上显示信息表示在备份组1中Switch A为Master路由器,Switch B为Backup路由器,缺省网关为202.38.160.100/25的主机通过Switch A访问Internet;备份组2中Switch A为Backup路由器,Switch B为Master路由器,缺省网关为202.38.160.200/25的主机通过Switch B访问Internet。
1.5 基于IPv6的VRRP典型配置举例
1.5.1 VRRP单备份组配置举例
1. 组网需求
Host A需要访问Internet上的Host B,Host A的缺省网关为1::10/64; Switch A和Switch B属于虚拟IPv6地址为1::10/64和FE80::10的备份组1; 当Switch A正常工作时,Host A发送给Host B的报文通过Switch A转发;当Switch
A出现故障时,Host A发送给Host B的报文通过Switch B转发。 2. 组网图
图1-10 VRRP单备份组配置组网图
Virtual IPv6 address: FE80::101::10/64Vlan-int2FE80::11::1/64Switch AGateway:1::10/64InternetVlan-int2FE80::21::2/64Host AHost BSwitch B
3. 配置步骤 (1) 配置Switch A # 配置VLAN2。
[SwitchA-vlan2] port ethernet 1/0/5 [SwitchA-vlan2] quit
[SwitchA] interface vlan-interface 2
[SwitchA-Vlan-interface2] ipv6 address fe80::1 link-local [SwitchA-Vlan-interface2] ipv6 address 1::1 64
# 创建备份组1,并配置备份组1的虚拟IPv6地址为FE80::10和1::10。
[SwitchA-Vlan-interface2] vrrp ipv6 vrid 1 virtual-ip fe80::10 link-local [SwitchA-Vlan-interface2] vrrp ipv6 vrid 1 virtual-ip 1::10
# 配置Switch A在备份组1中的优先级为110。