VRRP基础实验
VRRP基础实验
Yang设备连接方式如图所示,网络中存在VLAN10、20,每个VLAN中部署一组VRRP,使用与VLAN ID相同的数值作为VRID,将S1配置为VLAN10的VRRP Master,将S2配置为VLAN20的VRRP Master。
同时在S1、S2、S3上部署MSTP,创建Instance 1、2,将VLAN10映射到MSTI 1、VLAN20映射到MSTI 2,将S1配置为MSTI 1的主根桥、MSTI 2的备份根桥,而将S2配置为MSTI 1的备份根桥、MSTI 2的主根桥。
VLANIF接口地址使用10.0.x.y/24,其中x为VRID组号,y为设备编号,VRIP使用10.0.x.254/24。
#创建VLAN
[S1]vlan batch 10 20
[S2]vlan batch 10 20
[S3]vlan batch 10 20
[S4]vlan batch 10 20
#将所有互联接口配置为Trunk接口,放通对应VLAN
略
#修改STP模式为MSTP
[S1]stp mode mstp
[S2]stp mode mstp
[S3]stp mode mstp
#配置MSTP
[S1]stp region-configuration
[S1-mst-region] region-name hcip
[S1-mst-region] revision-level 1
[S1-mst-region] instance 1 vlan 10
[S1-mst-region] instance 2 vlan 20
[S1-mst-region] active region-configuration
Info: This operation may take a few seconds. Please wait for a moment…done.
[S1-mst-region] quit
[S2]stp region-configuration
[S2-mst-region] region-name hcip
[S2-mst-region] revision-level 1
[S2-mst-region] instance 1 vlan 10
[S2-mst-region] instance 2 vlan 20
[S2-mst-region] active region-configuration
Info: This operation may take a few seconds. Please wait for a moment…done.
[S2-mst-region] quit
[S3]stp region-configuration
[S3-mst-region] region-name hcip
[S3-mst-region] revision-level 1
[S3-mst-region] instance 1 vlan 10
[S3-mst-region] instance 2 vlan 20
[S3-mst-region] active region-configuration
Info: This operation may take a few seconds. Please wait for a moment…done.
[S3-mst-region] quit
#配置SW1为MSTI1的根桥、MSTI2的备份根桥
[S1]stp instance 1 root primary
[S1]stp instance 2 root secondary
#配置SW2为MSTI2的根桥、MSTI1的备份根桥
[S2]stp instance 1 root secondary
[S2]stp instance 2 root primary
#在S1上查看MSTI1的状态和统计信息摘要
S1上所有接口都是指定接口,S1为MSTI1的根桥。
#在S2上查看MSTI2的状态和统计信息摘要
S2上所有接口都是指定接口,S2为MSTI1的根桥。
VRRP基础配置
在S1、S2均创建VLANIF 10、20,分别加入VRRP组10、20,手动配置VRRP优先级,使得S1的VLAN10成为VRRP Master、S2的VLAN20成为VRRP Master。
#创建VLANIF
[S1]interface Vlanif10
[S1-Vlanif10] ip address 10.0.10.1 255.255.255.0
[S1-Vlanif10] quit
[S1]interface Vlanif20
[S1-Vlanif20] ip address 10.0.20.1 255.255.255.0
[S1-Vlanif20] quit
[S2]interface Vlanif10
[S2-Vlanif10] ip address 10.0.10.2 255.255.255.0
[S2-Vlanif10] quit
[S2]interface Vlanif20
[S2-Vlanif20] ip address 10.0.20.2 255.255.255.0
[S2-Vlanif20] quit
#S1上配置VRRP
[S1]interface Vlanif 10
[S1-Vlanif10] vrrp vrid 10 virtual-ip 10.0.10.254
[S1-Vlanif10] vrrp vrid 10 priority 120
[S1-Vlanif10] quit
[S1]interface Vlanif 20
[S1-Vlanif20] vrrp vrid 20 virtual-ip 10.0.20.254
[S1-Vlanif20] quit
配置VLAN10的VRRP优先级为120,VLAN20保持默认的100。
#S2上配置VRRP
[S2]interface Vlanif10
[S2-Vlanif10] vrrp vrid 10 virtual-ip 10.0.10.254
[S2-Vlanif10] quit
[S2]interface Vlanif20
[S2-Vlanif20] vrrp vrid 20 virtual-ip 10.0.20.254
[S2-Vlanif20] vrrp vrid 20 priority 120
[S2-Vlanif20] quit
配置VLAN20的VRRP优先级为120,VLAN10保持默认的100。
#查看VRRP组状态
配置VRRP与BFD联动进行快速切换
在S1、S2上配置BFD单跳检测,检测VLANIF接口之间的连通性,将VRRP与BFD联动,当BFD会话状态Down时,增加VRRP Backup设备的优先级。
#在S1上配置BFD会话
[S1]bfd
[S1-bfd] quit
[S1]bfd vlanif10 bind peer-ip 10.0.10.2 interface Vlanif10
[S1-bfd-session-vlanif10] discriminator local 1
[S1-bfd-session-vlanif10] discriminator remote 2
[S1-bfd-session-vlanif10] min-tx-interval 100
[S1-bfd-session-vlanif10] min-rx-interval 100
[S1-bfd-session-vlanif10] commit
[S1-bfd-session-vlanif10] quit
[S1]bfd vlanif20 bind peer-ip 10.0.20.2 interface Vlanif20
[S1-bfd-session-vlanif20] discriminator local 11
[S1-bfd-session-vlanif20] discriminator remote 22
[S1-bfd-session-vlanif20] min-tx-interval 100
[S1-bfd-session-vlanif20] min-rx-interval 100
[S1-bfd-session-vlanif20] commit
[S1-bfd-session-vlanif20] quit
#在S2上配置BFD会话
[S2]bfd
[S2-bfd] quit
[S2]bfd vlanif10 bind peer-ip 10.0.10.1 interface Vlanif10
[S2-bfd-session-vlanif10] discriminator local 2
[S2-bfd-session-vlanif10] discriminator remote 1
[S2-bfd-session-vlanif10] min-tx-interval 100
[S2-bfd-session-vlanif10] min-rx-interval 100
[S2-bfd-session-vlanif10] commit
[S2-bfd-session-vlanif10] quit
[S2]bfd vlanif20 bind peer-ip 10.0.20.1 interface Vlanif20
[S2-bfd-session-vlanif20] discriminator local 22
[S2-bfd-session-vlanif20] discriminator remote 11
[S2-bfd-session-vlanif20] min-tx-interval 100
[S2-bfd-session-vlanif20] min-rx-interval 100
[S2-bfd-session-vlanif20] commit
[S2-bfd-session-vlanif20] quit
#检查BFD会话状态
此时S1、S2上BFD会话状态都为Up。
#配置VRRP与BFD联动
[S1]interface Vlanif20
[S1-Vlanif20] vrrp vrid 20 track bfd-session 11 increased 30
[S1-Vlanif20] quit
[S2]interface Vlanif10
[S2-Vlanif10] vrrp vrid 10 track bfd-session 2 increased 30
[S2-Vlanif10] quit
注意,此处的bfd-session号为本地的BFD discriminator,只需要在Backup状态的接口上配置联动,BFD会话Down时增加本地的VRRP优先级。
#关闭S1上所有接口,模拟链路故障
[S1]interface GigabitEthernet0/0/10
[S1-GigabitEthernet0/0/10] shutdown
[S1-GigabitEthernet0/0/10] quit
[S1]interface GigabitEthernet0/0/11
[S1-GigabitEthernet0/0/11] shutdown
[S1-GigabitEthernet0/0/11] quit
[S1]interface GigabitEthernet0/0/12
[S1-GigabitEthernet0/0/12] shutdown
[S1-GigabitEthernet0/0/12] quit
#在S2上查看BFD会话状态
此时两个BFD会话状态立马变为Down。
#在S2上查看VRRP组状态
VRRP组10、20的Master此时都是S2。
#在S2上查看VRRP组的状态和配置参数信息