2023.3.21--9.38
华为交换机核心交换机VRRP负载均衡+OSPF+DHCP+VLAN+Hybird接口
拓扑图
注意事项
请确保该场景下互联接口的STP处于未使能状态。同时将互连接口退出VLAN1,避免形成环路。
因为在使能STP的环形网络中,如果用交换机的VLANIF接口构建三层网络,会导致某个端口被阻塞,从而导致三层业务不能正常运行。
STP
[CSW-A]dis stp brief
MSTID Port Role STP State Protection
0 GigabitEthernet0/0/1 ALTE DISCARDING NONE
0 GigabitEthernet0/0/2 ROOT FORWARDING NONE
//可以看到,开局CSW-A的g 0/0/1端口因为STP被阻塞
配置
SW配置
#
sysname SW
#
vlan batch 100 200
#
interface Vlanif100
ip address 192.168.1.1 255.255.255.0
#
interface Vlanif200
ip address 192.168.2.1 255.255.255.0
#
interface GigabitEthernet0/0/1
port link-type trunk
port trunk allow-pass vlan 100
#
interface GigabitEthernet0/0/2
port link-type trunk
port trunk allow-pass vlan 200
#
ospf 1
area 0.0.0.0
network 192.168.1.0 0.0.0.255
network 192.168.2.0 0.0.0.255
CSW-A配置
#
sysname CSW-A
#
vlan batch 100 300 400
#
dhcp enable
#
ip pool vlan300
gateway-list 10.1.20.111
network 10.1.20.0 mask 255.255.255.0
dns-list 114.114.114.114
#
ip pool vlan400
gateway-list 10.1.50.111
network 10.1.50.0 mask 255.255.255.0
dns-list 114.114.114.114
#
interface Vlanif1
#
interface Vlanif100
ip address 192.168.1.2 255.255.255.0
#
interface Vlanif300
ip address 10.1.20.1 255.255.255.0
vrrp vrid 1 virtual-ip 10.1.20.111
vrrp vrid 1 priority 120
vrrp vrid 1 preempt-mode timer delay 20
dhcp select global
#
interface Vlanif400
ip address 10.1.50.2 255.255.255.0
vrrp vrid 2 virtual-ip 10.1.50.111
dhcp select global
#
interface GigabitEthernet0/0/1
port link-type trunk
port trunk allow-pass vlan 100
#
interface GigabitEthernet0/0/2
port link-type trunk
port trunk allow-pass vlan 300 400
#
ospf 1
area 0.0.0.0
network 192.168.1.0 0.0.0.255
network 10.1.20.0 0.0.0.255
network 10.1.50.0 0.0.0.255
配置完CSW-A后,查看路由表,可以发现没有OSPF路由,原因是STP协议使g0/0/1阻塞了,发送不了OSPF报文;
CSW-B配置
#
sysname CSW-B
#
vlan batch 200 300 400
#
dhcp enable
#
ip pool vlan300
gateway-list 10.1.20.111
network 10.1.20.0 mask 255.255.255.0
dns-list 114.114.114.114
#
ip pool vlan400
gateway-list 10.1.50.111
network 10.1.50.0 mask 255.255.255.0
dns-list 114.114.114.114
#
interface Vlanif200
ip address 192.168.2.2 255.255.255.0
#
interface Vlanif300
ip address 10.1.20.2 255.255.255.0
vrrp vrid 1 virtual-ip 10.1.20.111
dhcp select global
#
interface Vlanif400
ip address 10.1.50.1 255.255.255.0
vrrp vrid 2 virtual-ip 10.1.50.111
vrrp vrid 2 priority 120
vrrp vrid 2 preempt-mode timer delay 20
dhcp select global
#
interface GigabitEthernet0/0/1
port link-type trunk
port trunk allow-pass vlan 200
#
interface GigabitEthernet0/0/2
port link-type trunk
port trunk allow-pass vlan 300 400
#
ospf 1
area 0.0.0.0
network 192.168.2.0 0.0.0.255
network 10.1.20.0 0.0.0.255
network 10.1.50.0 0.0.0.255
switch配置
#
sysname switch
#
vlan batch 300 400
#
interface GigabitEthernet0/0/1
port link-type trunk
port trunk allow-pass vlan 300 400
#
interface GigabitEthernet0/0/2
port link-type trunk
port trunk allow-pass vlan 300 400
#
interface GigabitEthernet0/0/3
port link-type access
port default vlan 300
#
interface GigabitEthernet0/0/4
port link-type access
port default vlan 400
注意事项
[CSW-A]dis ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 11 Routes : 13
Destination/Mask Proto Pre Cost Flags NextHop Interface
10.1.20.0/24 Direct 0 0 D 10.1.20.1 Vlanif300
10.1.20.1/32 Direct 0 0 D 127.0.0.1 Vlanif300
10.1.20.111/32 Direct 0 0 D 127.0.0.1 Vlanif300
10.1.50.0/24 Direct 0 0 D 10.1.50.2 Vlanif400
10.1.50.2/32 Direct 0 0 D 127.0.0.1 Vlanif400
10.1.50.111/32 OSPF 10 2 D 10.1.50.1 Vlanif400
OSPF 10 2 D 10.1.20.2 Vlanif300
127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0
127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0
192.168.1.0/24 Direct 0 0 D 192.168.1.2 Vlanif100
192.168.1.2/32 Direct 0 0 D 127.0.0.1 Vlanif100
192.168.2.0/24 OSPF 10 2 D 10.1.50.1 Vlanif400
OSPF 10 2 D 10.1.20.2 Vlanif300
//可以看到,CSW-A路由表中,到192.168.2.0段的下一跳为10.1.20.2和10.1.50.1;
此两条路由是CSW-B的ip,原因是CSW-A的g0/0/1接口由于STP导致阻塞,所以路由只能绕道,需要在各接口上关闭STP
测试
pc1,2 ping pc3;
关闭CSW-A的g0/0/1口或者g0/0/2口;测试断开时间;
icmp报文不可达时间极短;
gaoshuai010107@163.com