网络断网、环路、IP 冲突?VRRP+MSTP+DHCP 联动方案一次性解决

一、实验拓扑及描述

1、这是一个由三台交换机组成的倒三角型二层交换网络;网络中有4个VLAN:101、200;接口编号如拓扑图所示;LSW1为接入层交换机,SW1、SW2为汇聚层交换机;

2、VLAN101对应的网段为172.16.101.0/24; VLAN200对应的网段为192.168.200.0/24;各VLAN的网关均为.254的地址,该地址为VRRP组的虚拟地址;

3、SW1的vlanif101的接口实际IP地址分别为:172.16.101.252;SW1的vlanif200接口实际IP地址分别为:192.168.200.253;

4、SW2的vlanif100和vlanif101的接口实际IP地址分别为: 172.16.101.253;SW2的vlanif200的接口实际IP地址分别为: 192.168.200.252。

二、实验需求

1、由于网络中VLAN较多,并且存在二层环路因此使用MSTP实现环路避免,同时实现负载分担。要求vlan101的流量主走PC1-LSW1-SW1这一侧链路,vlan200的流量主走PC2-LSW1-SW2这一侧链路;

2、为了提高网络的网关层冗余能力,在SW1及SW2的vlanif101、 vlanif200、上部署VRRP,一共2组。

三、实现步骤及配置
接入LSW1的配置如下:

sysname LSW1

# 在LSW1上创建VLAN,并将接口加入相应的VLAN

vlan batch 101 200

# 配置HXSW的接口信息

interface Ethernet0/0/1

description to PC1

port link-type access

port default vlan 200

interface Ethernet0/0/2

description to PC2

port link-type access

port default vlan 101

interface GigabitEthernet0/0/1

description to SW1G0/0/0

port link-type trunk

undo port trunk allow-pass vlan 1

port trunk allow-pass vlan 101 200

interface GigabitEthernet0/0/2

description to SW2G0/0/0

port link-type trunk

undo port trunk allow-pass vlan 1

port trunk allow-pass vlan 101 200

# 配置MSTP,将vlan101映射到实例1,将vlan200映射到实例2

# 在LSW1上,MSTP实例1及实例2的优先级保持默认32768

stp enable

stp mode mstp

stp region-configuration

region-name huawei

instance 1 vlan 101

instance 2 vlan 200

active region-configuration

SW1 的配置如下:

sysname SW1

vlan batch 101 200 255

dhcp enable

interface GigabitEthernet0/0/1

port link-type trunk

undo port trunk allow-pass vlan 1

port trunk allow-pass vlan 101 200

interface GigabitEthernet0/0/21

port link-type trunk

undo port trunk allow-pass vlan 1

port trunk allow-pass vlan 101 200

interface GigabitEthernet0/0/24

description to ISPG0/0/1

port link-type access

port default vlan 255

# 配置MSTP,将vlan101映射到实例1,将vlan200映射到实例2

# 将SW1的MSTP设置为实例1的主根,实例2的次根

stp enable

stp mode mstp

stp region-configuration

region-name huawei

instance 1 vlan 101

instance 2 vlan 200

active region-configuration

stp instance 1 root primary

stp instance 2 root secondary

# 配置vlanif101、vlanif200,分别加入VRRP组101,200,

# 其中SW1为VRRP组101的Master,为组200的Backup

interface Vlanif101

ip address 172.16.101.252 255.255.255.0

vrrp vrid 101 virtual-ip 172.16.101.254

vrrp vrid 101 priority 120

vrrp vrid 101 track interface GigabitEthernet0/0/24 reduced 35

interface Vlanif200

ip address 192.168.200.253 255.255.255.0

vrrp vrid 200 virtual-ip 192.168.200.254

interface Vlanif255

ip address 10.10.255.1 255.255.255.252

# 配置DHCP

ip pool vlan101

gateway-list 172.16.101.254

network 172.16.101.0 mask 255.255.255.0

lease day 3 hour 12 minute 0

dns-list 8.8.8.8 114.114.114.114

quit

ip pool vlan200

gateway-list 192.168.200.254

network 192.168.200.0 mask 255.255.255.0

excluded-ip-address 192.168.200.230 192.168.200.253

lease day 3 hour 12 minute 0

dns-list 8.8.8.8 114.114.114.114

interface Vlanif101

dhcp select global

interface Vlanif200

dhcp select global

# 配置默认路由

ip route-static 0.0.0.0 0.0.0.0 10.10.255.2

SW2 的配置如下:

sysname SW2

vlan batch 101 200 254

interface GigabitEthernet0/0/1

port link-type trunk

undo port trunk allow-pass vlan 1

port trunk allow-pass vlan 101 200

interface GigabitEthernet0/0/21

port link-type trunk

undo port trunk allow-pass vlan 1

port trunk allow-pass vlan 101 200

interface GigabitEthernet0/0/24

description to ISPG0/0/1

port link-type access

port default vlan 254

# 配置MSTP,将vlan101映射到实例1,将vlan200映射到实例2

# 将SW1的MSTP设置为实例1的主根,实例2的次根

stp enable

stp mode mstp

stp region-configuration

region-name huawei

instance 1 vlan 101

instance 2 vlan 200

active region-configuration

stp instance 1 root secondary

stp instance 2 root primary

# 配置vlanif101、vlanif200,分别加入VRRP组101,200

# 其中SW1为VRRP组101的Backup,为组200的Master

interface Vlanif101

ip address 172.16.101.253 255.255.255.0

vrrp vrid 101 virtual-ip 172.16.101.254

vrrp vrid 101 track interface GigabitEthernet0/0/24 reduced 35

interface Vlanif200

ip address 192.168.200.252 255.255.255.0

vrrp vrid 200 virtual-ip 192.168.200.254

vrrp vrid 200 priority 120

vrrp vrid 200 track interface GigabitEthernet0/0/24 reduced 35

interface Vlanif254

ip address 10.10.254.1 255.255.255.252

# 配置DHCP

ip pool vlan101

gateway-list 172.16.101.254

network 172.16.101.0 mask 255.255.255.0

lease day 3 hour 12 minute 0

dns-list 8.8.8.8 114.114.114.114

quit

ip pool vlan200

gateway-list 192.168.200.254

network 192.168.200.0 mask 255.255.255.0

excluded-ip-address 192.168.200.230 192.168.200.253

lease day 3 hour 12 minute 0

dns-list 8.8.8.8 114.114.114.114

interface Vlanif101

dhcp select global

interface Vlanif200

dhcp select global

# 配置默认路由

ip route-static 0.0.0.0 0.0.0.0 10.10.254.2

ISP 路由器:

sysname ISP

interface GigabitEthernet0/0/1

ip address 10.10.255.2 255.255.255.252

interface GigabitEthernet0/0/2

ip address 10.10.254.2 255.255.255.252

interface LoopBack0

ip address 6.6.6.6 255.255.255.255

ip route-static 0.0.0.0 0.0.0.0 10.10.255.1

ip route-static 0.0.0.0 0.0.0.0 10.10.254.1

完成配置后,各VLAN的用户都能够ping通6.6.6.6:

在LSW1上看看:

我们看到,MSTP实例1中被Block掉的端口是GE0/0/2口;MSTP实例2中被Block掉的端口是GE0/0/1,符合需求。再去SW1上看看VRRP组的状态:

查看dhc已经租用的IP

<SW1>dis ip pool name vlan101 used

dis ip pool name vlan101 [all | conflict | expired | used]

conflict:可以查看地址池中发生冲突的IPv4地址信息。

Expired:可以查看地址池中过期的IPv4地址信息。

Used:可以查看地址池中已使用的IPv4地址信息。

相关推荐
s_w.h几秒前
【 linux 】进程的调度算法
linux·运维·服务器
c++逐梦人几秒前
多路转接epoll
linux·网络·epoll
天若有情6731 分钟前
Deepseek-V4-Flash-20260423 深度评测与实战指南
java·大数据·网络·ai
r-t-H2 分钟前
KVM虚拟化与Docker基础实践-第三章
linux·运维·nginx·docker·容器
艾莉丝努力练剑4 分钟前
【Linux网络】Linux 网络编程:传输层UDP
linux·运维·服务器·网络·计算机网络·udp
陈eaten5 分钟前
centos 7等保整改学习
linux·运维·服务器·网络安全·centos·等保
牢七6 分钟前
契约锁分析
linux·运维·服务器
LB21128 分钟前
C++通讯录课设(西安石油大学)
开发语言·c++·算法
承渊政道12 分钟前
Linux系统学习【进程概念从入门到深入理解】
linux·服务器·笔记·学习·ubuntu·系统架构·bash
无忧.芙桃15 分钟前
进程间通信的基本概念(上)
linux·运维·服务器