VLAN 配置实例:设备填写不同的 IP 网段即可自动加入对应 VLAN,怎么做?

本期给大家分享VLAN相关知识。

组网需求

某数据中心拥有多种业务,如办公业务、生产业务、灾备业务,每种业务使用的IP地址网段各不相同。为了便于管理,现需要将同一种类型业务划分到同一VLAN中,不同类型的业务划分到不同VLAN中。

如图1所示,Switch连接有办公业务服务器、生产业务服务器、灾备业务服务器,不同业务的IP地址网段各不相同。现需要将不同类型的业务划分到不同的VLAN中,通过不同的VLAN ID分流到不同的远端网络上以实现业务互通。

图片 图1 基于子网划分VLAN组网图

配置思路

采用如下的思路配置基于子网划分VLAN:

创建VLAN,确定每种业务所属的VLAN。关联子网和VLAN,实现根据报文中的源IP地址或指定网段确定VLAN。配置接口加入VLAN,实现基于子网的VLAN通过当前接口。使能基于子网划分VLAN。操作步骤

第一步:创建VLAN

在Switch上创建VLAN100、VLAN200和VLAN300。

复制
<HUAWEI> system-view [~HUAWEI] sysname Switch [*HUAWEI] commit [~Switch] vlan batch 100 200 300 [*Switch] commit1.2.3.4.5.

第二步:配置接口

在Switch上配置接口10GE1/0/5、10GE1/0/6、10GE1/0/7为Hybrid类型,分别以untagged方式加入VLAN100、VLAN200和VLAN300。并使能基于子网划分VLAN功能。

复制
[~Switch] interface 10ge 1/0/5 [~Switch-10GE1/0/5] port link-type hybrid [*Switch-10GE1/0/5] port hybrid untagged vlan 100 [*Switch-10GE1/0/5] ip-subnet-vlan enable [*Switch-10GE1/0/5] quit [*Switch] interface 10ge 1/0/6 [*Switch-10GE1/0/6] port link-type hybrid [*Switch-10GE1/0/6] port hybrid untagged vlan 200 [*Switch-10GE1/0/6] ip-subnet-vlan enable [*Switch-10GE1/0/6] quit [*Switch] interface 10ge 1/0/7 [*Switch-10GE1/0/7] port link-type hybrid [*Switch-10GE1/0/7] port hybrid untagged vlan 300 [*Switch-10GE1/0/7] ip-subnet-vlan enable [*Switch-10GE1/0/7] quit [*Switch] commit1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.

第三步:接口划入VLAN

Switch上配置接口10GE1/0/2加入VLAN100。

复制
[~Switch] interface 10ge 1/0/2 [~Switch-10GE1/0/2] port link-type trunk [*Switch-10GE1/0/2] port trunk allow-pass vlan 100 [*Switch-10GE1/0/2] quit [*Switch] commit1.2.3.4.5.

在Switch上配置接口10GE1/0/3加入VLAN200。

复制
[~Switch] interface 10ge 1/0/3 [~Switch-10GE1/0/3] port link-type trunk [*Switch-10GE1/0/3] port trunk allow-pass vlan 200 [*Switch-10GE1/0/3] quit [*Switch] commit1.2.3.4.5.

在Switch上配置接口10GE1/0/4加入VLAN300。

复制
[~Switch] interface 10ge 1/0/4 [~Switch-10GE1/0/4] port link-type trunk [*Switch-10GE1/0/4] port trunk allow-pass vlan 300 [*Switch-10GE1/0/4] quit [*Switch] commit1.2.3.4.5.

第四步:配置基于子网划分VLAN

在Switch上配置VLAN100与IP地址192.168.1.2/24关联。

复制
[~Switch] vlan 100 [~Switch-vlan100] ip-subnet-vlan 1 ip 192.168.1.2 24 [*Switch-vlan100] quit1.2.3.

在Switch上配置VLAN200与IP地址192.168.2.2/24关联。

复制
[*Switch] vlan 200 [*Switch-vlan200] ip-subnet-vlan 1 ip 192.168.2.2 24 [*Switch-vlan200] quit1.2.3.

在Switch上配置VLAN300与IP地址192.168.3.2/24关联。

复制
[*Switch] vlan 300 [*Switch-vlan300] ip-subnet-vlan 1 ip 192.168.3.2 24 [*Switch-vlan300] quit [*Switch] commit1.2.3.4.
测试配置结果

在Switch上执行以下命令,显示信息如下:

复制
[~Switch] display ip-subnet-vlan vlan all IP-subnet-VLAN count: 3 total count: 3 ---------------------------------------------------------------- VLAN Index IpAddress SubnetMask Priority ---------------------------------------------------------------- 100 1 192.168.1.2 255.255.255.0 0 200 1 192.168.2.2 255.255.255.0 0 300 1 192.168.3.2 255.255.255.0 0 ----------------------------------------------------------------1.2.3.4.5.6.7.8.9.

生产业务、办公业务和灾备业务分别可以和生产中心、园区办公网、灾备数据中心互相ping通,但是生产业务不能和园区办公网、灾备数据中心ping通,办公业务不能和生产中心、灾备数据中心ping通,灾备业务不能和生产中心、园区办公网ping通。

THE END