网工配置命令基础总结(2)----VRRP配置

目录

1.配置VRRP主备备份

2.配置VRRP负载分担

3.配置VRRP域BFD联动实现快速切换


VRRP

虚拟路由冗余协议 VRRP(Virtual Router Redundancy Protocol)通过把几台路由设备联合组成一台虚拟的路由设备,将虚拟网关设备的 IP 地址作为用户的默认网关实现与外部网络通信。当网关 设备发生故障时,VRRP 机制能够选举新的网关设备承担数据流量,从而保障网络的可靠通信。

常用配置命令

1.执行命令 vrrp vrid virtual-router-id virtual-ip virtual-address,接口视图创建 VRRP 备份组并给备份组配置虚拟 IP 地址。
2.执行命令 vrrp vrid virtual-router-id priority priority-value,配置交换机在备
份组中的优先级。 缺省情况下,优先级的取值是100。数值越大,优先级越高,优先级越高,越可能成为master 设备。
3.执行命令 vrrp vrid virtual-router-id preempt-mode timer delay delay-value,
配置备份组中交换机的抢占延迟时间。
4.执行命令 vrrp vrid virtual-router-id track bfd-session { bfd-session-id | 
session-name bfd-configure-name } [ increased value-increased | reduced 
value-reduced ],备设备 Backup 接口视图下,配置 VRRP 与 BFD 联动。
5. 执 行 命 令 vrrp vrid virtual-router-id track interface interface-type 
interface-number [ increased value-increased | reduced value-reduced ],配置 VRRP
与接口状态联动监视上行接口。

1.配置VRRP主备备份

用户希望实现:

•正常情况下,主机以 SwitchA 为默认网关接入 Internet,当 SwitchA 故障时,SwitchB 接 替作为网关继续进行工作,实现网关的冗余备份。

•SwitchA 故障恢复后,可以在20秒内重新成为网关。

思路: 

•配置各设备接口 IP 地址及路由协议,使各设备间网络层连通。

•在 SwitchA 和 SwitchB 上配置 VRRP 备份组。其中,SwitchA 上配置较高优先级和20秒抢占 延时,作为 Master 设备承担流量转发;SwitchB 上配置较低优先级,作为备用交换机,实现网关冗余备 份。

•在 SwitchA、SwitchB 和 Switch上配置破环协议,防止环路的产生(此处以配置 STP 为例)

SwitchA的配置

1、配置设备间的网络互连
# 配置 SwitchA 设备各接口的 IP 地址。
<Quidway> system-view
[Quidway] sysname SwitchA
[SwitchA] vlan batch 100 300
[SwitchA] interface ethernet 0/0/1
[SwitchA-Ethernet0/0/1] port link-type access
[SwitchA-Ethernet0/0/1] port default vlan 300
[SwitchA-Ethernet0/0/1] quit
[SwitchA] interface ethernet 0/0/2
[SwitchA-Ethernet0/0/2] port link-type access
[SwitchA-Ethernet0/0/2] port default vlan 100
[SwitchA-Ethernet0/0/2] quit
[SwitchA] interface ethernet 0/0/5
[SwitchA-Ethernet0/0/5] port link-type access
[SwitchA-Ethernet0/0/5] port hybrid untagged vlan 100
[SwitchA-Ethernet0/0/5] quit
[SwitchA] interface vlanif 100
[SwitchA-Vlanif100] ip address 10.1.1.1 24
[SwitchA-Vlanif100] quit
[SwitchA] interface vlanif 300
[SwitchA-Vlanif300] ip address 192.168.1.1 24
[SwitchA-Vlanif300] quit
2、配置 VRRP 备份组
# 在 SwitchA 上创建 VRRP 备份组1,配置 SwitchA 在该备份组中的优先级为120,并配置抢占时
间为20秒。
[SwitchA] interface vlanif 100
[SwitchA-Vlanif100] vrrp vrid 1 virtual-ip 10.1.1.111
[SwitchA-Vlanif100] vrrp vrid 1 priority 120
[SwitchA-Vlanif100] vrrp vrid 1 preempt-mode timer delay 20
[SwitchA-Vlanif100] quit
3、配置 SwitchA 和 SwitchC 间采用静态路由协议进行互连。
[SwitchA]ip route-static 0.0.0.0 0.0.0.0 192.168.1.2
4、配置 STP 协议
# 在 SwitchA 上全局使能 STP。
[SwitchA]stp enable

SwitchB的配置

1、配置设备间的网络互连
# 配置 SwitchB 设备各接口的 IP 地址。
<Quidway> system-view
[Quidway] sysname SwitchB
[SwitchB] vlan batch 100 200
[SwitchB] interface ethernet 0/0/1
[SwitchB-Ethernet0/0/1] port link-type access
[SwitchB-Ethernet0/0/1] port default vlan 200
[SwitchB-Ethernet0/0/1] quit
[SwitchB] interface ethernet 0/0/2
[SwitchB-Ethernet0/0/2] port link-type access
[SwitchB-Ethernet0/0/2] port default vlan 100
[SwitchB-Ethernet0/0/2] quit
[SwitchB] interface ethernet 0/0/5
[SwitchB-Ethernet0/0/5] port link-type access
[SwitchB-Ethernet0/0/5] port hybrid untagged vlan 100
[SwitchB-Ethernet0/0/5] quit
[SwitchB] interface vlanif 100
[SwitchB-Vlanif100] ip address 10.1.1.2 24
[SwitchB-Vlanif100] quit
[SwitchB] interface vlanif 300
[SwitchB-Vlanif300] ip address 192.168.2.1 24
[SwitchB-Vlanif300] quit
1、配置 VRRP 备份组
# 在 SwitchB 上创建 VRRP 备份组1,其在该备份组中的优先级为缺省值100。
[SwitchB] interface vlanif 100
[SwitchB-Vlanif100] vrrp vrid 1 virtual-ip 10.1.1.111
[SwitchB-Vlanif100] quit
2、配置 SwitchB 和 SwitchC 间采用静态路由协议进行互连。
[SwitchA]ip route-static 0.0.0.0 0.0.0.0 192.168.2.2
3、配置 STP 协议
# 在 SwitchB 上全局使能 STP。
[SwitchB]stp enable

SwitchC的配置

1、配置设备间的网络互连
# 配置 SwitchC 设备各接口的 IP 地址。
<Quidway> system-view
[Quidway] sysname SwitchC
[SwitchC] vlan batch 200 300 400
[SwitchC] interface ethernet 0/0/1
[SwitchC-Ethernet0/0/1] port link-type access
[SwitchC-Ethernet0/0/1] port default vlan 300
[SwitchC-Ethernet0/0/1] quit
[SwitchC] interface ethernet 0/0/2
[SwitchC-Ethernet0/0/2] port link-type access
[SwitchC-Ethernet0/0/2] port default vlan 200
[SwitchC-Ethernet0/0/2] quit
[SwitchC] interface ethernet 0/0/3
[SwitchC-Ethernet0/0/5] port link-type access
[SwitchC-Ethernet0/0/5] port hybrid untagged vlan 400
[SwitchC-Ethernet0/0/5] quit
[SwitchC] interface vlanif 200
[SwitchC-Vlanif100] ip address 192.168.2.2 24
[SwitchC-Vlanif100] quit
[SwitchC] interface vlanif 300
[SwitchC-Vlanif300] ip address 192.168.1.2 24
[SwitchC-Vlanif300] quit
[SwitchC] interface vlanif 400
[SwitchC-Vlanif300] ip address 20.1.1.100 24
[SwitchC-Vlanif300] quit
2、配置 SwitchC 和 Switch A 、SwitchB 间采用静态路由协议进行互连。
[SwitchC]ip route-static 10.1.1.0 255.255.255.0 192.168.1.1
[SwitchC]ip route-static 10.1.1.0 255.255.255.0 192.168.2.1
Switch 设备配置如下:
1、配置 Switch 的二层透传功能。
<Quidway> system-view
[Quidway] sysname Switch
[Switch] vlan 100
[Switch-vlan100] quit
[Switch] interface ethernet 0/0/1
[Switch-Ethernet0/0/1] port link-type access
[Switch-Ethernet0/0/1] port default vlan 100
[Switch-Ethernet0/0/1] quit
[Switch] interface ethernet 0/0/2
[Switch-Ethernet0/0/2] port link-type access
[Switch-Ethernet0/0/2] port default vlan 100
[Switch-Ethernet0/0/2] quit
2、配置 STP 协议
# 在 SwitchC 上全局使能 STP。
[SwitchC]stp enable

2.配置VRRP负载分担

如图所示,HostA 和 HostC 通过 Switch 双归属到 SwitchA 和 SwitchB。为减轻 SwitchA 上数据流量的承载压力,HostA 以 SwitchA 为默认网关接入 Internet,SwitchB 作为备份网关;HostC 以 SwitchB 为默认网关接入 Internet,SwitchA 作为备份网关,以实现流量的负载均衡。

 

 思路:

•配置各设备接口 IP 地址及路由协议,使各设备间网络层连通。

•在 SwitchA 和 SwitchB 上创建 VRRP 备份组1和 VRRP 备份组2,在备份组1中,配置 SwitchA 为 Master 设备,SwitchB 为 Backup 设备;在备份组2中,配置 SwitchB 为 Master 设备,SwitchA 为 Backup 设备,实现流量的负载均衡。

配置SwitchA设备各接口的IP地址

1. 配置设备间的网络互连
# 配置 SwitchA 设备各接口的 IP 地址。
<Quidway> system-view
[Quidway] sysname SwitchA
[SwitchA] vlan batch 100 300
[SwitchA] interface ethernet 0/0/1
[SwitchA-Ethernet0/0/1] port link-type access
[SwitchA-Ethernet0/0/1] port default vlan 300
[SwitchA-Ethernet0/0/1] quit
[SwitchA] interface ethernet 0/0/2
[SwitchA-Ethernet0/0/2] port link-type access
[SwitchA-Ethernet0/0/2] port default vlan 100
[SwitchA-Ethernet0/0/2] quit
[SwitchA] interface vlanif 100
[SwitchA-Vlanif100] ip address 10.1.1.1 24
[SwitchA-Vlanif100] quit
[SwitchA] interface vlanif 300
[SwitchA-Vlanif300] ip address 192.168.1.1 24
[SwitchA-Vlanif300] quit
2. 配置 VRRP 备份组
# 在 SwitchA 上创建 VRRP 备份组1,配置 SwitchA 在该备份组中的优先级为120,抢占延时为20
秒,作为 Master 设备;
[SwitchA] interface vlanif 100
[SwitchA-Vlanif100] vrrp vrid 1 virtual-ip 10.1.1.111
[SwitchA-Vlanif100] vrrp vrid 1 priority 120
[SwitchA-Vlanif100] vrrp vrid 1 preempt-mode timer delay 20
[SwitchA-Vlanif100] quit
# 在 SwitchA 上创建 VRRP 备份组2,SwitchA 在该备份组中的优先级为缺省值,作为 Backup 设
备。
[SwitchA] interface vlanif 100
[SwitchA-Vlanif100] vrrp vrid 2 virtual-ip 10.1.1.112
[SwitchA-Vlanif100] quit
3. 配置 SwitchA 和 SwitchC 间采用静态路由协议进行互连。
[SwitchA]ip route-static 0.0.0.0 0.0.0.0 192.168.1.2

SwitchB设备配置

1. 配置设备间的网络互连
# 配置 SwitchB 设备各接口的 IP 地址。
<Quidway> system-view
[Quidway] sysname SwitchB
[SwitchB] vlan batch 100 200
[SwitchB] interface ethernet 0/0/1
[SwitchB-Ethernet0/0/1] port link-type access
[SwitchB-Ethernet0/0/1] port default vlan 200
[SwitchB-Ethernet0/0/1] quit
[SwitchB] interface ethernet 0/0/2
[SwitchB-Ethernet0/0/2] port link-type access
[SwitchB-Ethernet0/0/2] port default vlan 100
[SwitchB-Ethernet0/0/2] quit
[SwitchB] interface vlanif 100
[SwitchB-Vlanif100] ip address 10.1.1.2 24
[SwitchB-Vlanif100] quit
[SwitchB] interface vlanif 200
[SwitchB-Vlanif300] ip address 192.168.2.1 24
[SwitchB-Vlanif300] quit
2. 配置 VRRP 备份组
# 在 SwitchB 上创建 VRRP 备份组2,配置 SwitchB 在该备份组中的优先级为120,抢占延时为20
秒,作为 Master 设备;
[SwitchB] interface vlanif 100
[SwitchB-Vlanif100] vrrp vrid 2 virtual-ip 10.1.1.112
[SwitchB-Vlanif100] vrrp vrid 2 priority 120
[SwitchB-Vlanif100] vrrp vrid 2 preempt-mode timer delay 20
[SwitchB-Vlanif100] quit
# 在 SwitchB 上创建 VRRP 备份组1,SwitchB 在该备份组中的优先级为缺省值,作为 Backup 设备。
[SwitchB] interface vlanif 100
[SwitchB-Vlanif100] vrrp vrid 1 virtual-ip 10.1.1.111
[SwitchB-Vlanif100] quit
3. 配置 SwitchB 和 SwitchC 间采用静态路由协议进行互连。
[SwitchB]ip route-static 0.0.0.0 0.0.0.0 192.168.1.2

Switch设备配置

1. 配置设备间的网络互连
# 配置 SwitchC 设备各接口的 IP 地址。
<Quidway> system-view
[Quidway] sysname SwitchC
[SwitchC] vlan batch 200 300 400
[SwitchC] interface ethernet 0/0/1
[SwitchC-Ethernet0/0/1] port link-type access
[SwitchC-Ethernet0/0/1] port default vlan 300
[SwitchC-Ethernet0/0/1] quit
[SwitchC] interface ethernet 0/0/2
[SwitchC-Ethernet0/0/2] port link-type access
[SwitchC-Ethernet0/0/2] port default vlan 200
[SwitchC-Ethernet0/0/2] quit
[SwitchC] interface ethernet 0/0/3
[SwitchC-Ethernet0/0/5] port link-type access
[SwitchC-Ethernet0/0/5] port hybrid untagged vlan 400
[SwitchC-Ethernet0/0/5] quit
[SwitchC] interface vlanif 200
[SwitchC-Vlanif100] ip address 192.168.2.2 24
[SwitchC-Vlanif100] quit
[SwitchC] interface vlanif 300
[SwitchC-Vlanif300] ip address 192.168.1.2 24
[SwitchC-Vlanif300] quit
[SwitchC] interface vlanif 400
[SwitchC-Vlanif300] ip address 20.1.1.100 24
[SwitchC-Vlanif300] quit
2. 配置 SwitchC 和 Switch A 、SwitchB 间采用静态路由协议进行互连。
[SwitchC]ip route-static 10.1.1.0 255.255.255.0 192.168.1.1
[SwitchC]ip route-static 10.1.1.0 255.255.255.0 192.168.2.1
Switch 设备配置如下:
1. 配置 Switch 的二层透传功能。
<Quidway> system-view
[Quidway] sysname Switch
[Switch] vlan 100
[Switch-vlan100] quit
[Switch] interface ethernet 0/0/1
[Switch-Ethernet0/0/1] port link-type access
[Switch-Ethernet0/0/1] port default vlan 100
[Switch-Ethernet0/0/1] quit
[Switch] interface ethernet 0/0/2
[Switch-Ethernet0/0/2] port link-type access
[Switch-Ethernet0/0/2] port default vlan 100
[Switch-Ethernet0/0/2] quit

3.配置VRRP域BFD联动实现快速切换

如图所示,局域网内的主机通过 Switch 双归属到部署了VRRP 备份组的 SwitchA 和SwitchB, 其中 SwitchA 为 Master。

当 SwitchA 或 SwitchA 到 SwitchB 间链路出现故障时,VRRP 报文协商需要一定的协商周期。为 了实现链路故障时快速切换,可以在链路中部署 BFD 链路检测机制,并配置 VRRP 监视 BFD 会话,实现当 主用接口或者链路出现 Down 时,备用设备迅速切换为 Master,承担网络流量,以减少故障对业务传输的影响。

 思路:

•配置各设备接口 IP 地址及路由协议,使网络层路由可达。

•在 SwitchA 和 SwitchB 上配置 VRRP 备份组,其中 SwitchA 的优先级为120,抢占延时为20 秒,作为 Master 设备;SwitchB 的优先级为缺省值,作为 Backup 设备,实现网关的主备备份。

•在 SwitchA 和 SwitchB 上配置静态 BFD 会话,监测备份组之间的链路。

•在 SwitchB 上配置 VRRP 与 BFD 联动,实现链路故障时 VRRP 备份组快速切换

SwitchA设备各接口的IP地址

# 配置 SwitchA 设备各接口的 IP 地址。
<Quidway> system-view
[Quidway] sysname SwitchA
[SwitchA] vlan batch 100 
[SwitchA] interface ethernet 0/0/1
[SwitchA-Ethernet0/0/1] port link-type access
[SwitchA-Ethernet0/0/1] port default vlan 100
[SwitchA-Ethernet0/0/1] quit
[SwitchA] interface vlanif 100
[SwitchA-Vlanif100] ip address 10.1.1.1 24
[SwitchA-Vlanif100] quit
2. 配置 VRRP 备份组
# 在 SwitchA 上创建 VRRP 备份组1,配置 SwitchA 在该备份组中的优先级为120,抢占延时为20
秒,作为 Master 设备;
[SwitchA] interface vlanif 100
[SwitchA-Vlanif100] vrrp vrid 1 virtual-ip 10.1.1.3
[SwitchA-Vlanif100] vrrp vrid 1 priority 120
[SwitchA-Vlanif100] vrrp vrid 1 preempt-mode timer delay 20
[SwitchA-Vlanif100] quit
3. 配置静态 BFD 会话
# 在 SwitchA 上配置 BFD 会话。
[SwitchA] bfd
[SwitchA-bfd] quit
[SwitchA] bfd atob bind peer-ip 10.1.1.2 interface vlanif 100
[SwitchA-bfd-session-atob] discriminator local 1
[SwitchA-bfd-session-atob] discriminator remote 2
[SwitchA-bfd-session-atob] min-rx-interval 100
[SwitchA-bfd-session-atob] min-tx-interval 100
[SwitchB-bfd-session-atob] commit
[SwitchA-bfd-session-atob] quit

SwitchB设备配置

1. 配置设备间的网络互连
# 配置 SwitchB 设备各接口的 IP 地址。
<Quidway> system-view
106
[Quidway] sysname SwitchB
[SwitchB] vlan batch 100 
[SwitchB] interface ethernet 0/0/1
[SwitchB-Ethernet0/0/1] port link-type access
[SwitchB-Ethernet0/0/1] port default vlan 100
[SwitchB-Ethernet0/0/1] quit
[SwitchB] interface vlanif 100
[SwitchB-Vlanif100] ip address 10.1.1.2 24
[SwitchB-Vlanif100] quit
2. 配置 VRRP 备份组
# 在 SwitchB 上创建 VRRP 备份组1,优先级为默认值100,作为 Slave 设备;
[SwitchB] interface vlanif 100
[SwitchB-Vlanif100] vrrp vrid 1 virtual-ip 10.1.1.3
3. 配置静态 BFD 会话
# 在 SwitchB 上配置 BFD 会话。
[SwitchB] bfd
[SwitchB-bfd] quit
[SwitchB] bfd atob bind peer-ip 10.1.1.1 interface vlanif 100
[SwitchB-bfd-session-atob] discriminator local 2
[SwitchB-bfd-session-atob] discriminator remote 1
[SwitchB-bfd-session-atob] min-rx-interval 100
[SwitchB-bfd-session-atob] min-tx-interval 100
[SwitchB-bfd-session-atob] commit
[SwitchB-bfd-session-atob] quit
4. 配置 VRRP 与 BFD 联动功能
# 在 SwitchB 上配置 VRRP 与 BFD 联动,当 BFD 会话状态 Down 时,SwitchB 的优先级增加40。
[SwitchB] interface vlanif 100
[SwitchB-Vlanif100] vrrp vrid 1 track bfd-session 2 increased 40 //bfd-session 
的取值和 local 的取值一样
[SwitchB-Vlanif100] quit

Switch的配置

# 配置 Switch 的二层透传能力
<Quidway> system-view
[Quidway] sysname Switch
107
[Switch] vlan 100
[Switch-vlan100] quit
[Switch] interface ethernet 0/0/1
[Switch-Ethernet0/0/1] port hybrid pvid vlan 100
[Switch-Ethernet0/0/1] port hybrid untagged vlan 100
[Switch-Ethernet0/0/1] quit
[Switch] interface ethernet 0/0/2
[Switch-Ethernet0/0/2] port hybrid pvid vlan 100
[Switch-Ethernet0/0/2] port hybrid untagged vlan 100
[Switch-Ethernet0/0/2] quit

  • 15
    点赞
  • 27
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值