VLAN 配置實(shí)例:設(shè)備填寫不同的 IP 網(wǎng)段即可自動(dòng)加入對(duì)應(yīng) VLAN,怎么做?
本期給大家分享VLAN相關(guān)知識(shí)。

組網(wǎng)需求
某數(shù)據(jù)中心擁有多種業(yè)務(wù),如辦公業(yè)務(wù)、生產(chǎn)業(yè)務(wù)、災(zāi)備業(yè)務(wù),每種業(yè)務(wù)使用的IP地址網(wǎng)段各不相同。為了便于管理,現(xiàn)需要將同一種類型業(yè)務(wù)劃分到同一VLAN中,不同類型的業(yè)務(wù)劃分到不同VLAN中。
如圖1所示,Switch連接有辦公業(yè)務(wù)服務(wù)器、生產(chǎn)業(yè)務(wù)服務(wù)器、災(zāi)備業(yè)務(wù)服務(wù)器,不同業(yè)務(wù)的IP地址網(wǎng)段各不相同?,F(xiàn)需要將不同類型的業(yè)務(wù)劃分到不同的VLAN中,通過不同的VLAN ID分流到不同的遠(yuǎn)端網(wǎng)絡(luò)上以實(shí)現(xiàn)業(yè)務(wù)互通。

圖片 圖1 基于子網(wǎng)劃分VLAN組網(wǎng)圖
配置思路
采用如下的思路配置基于子網(wǎng)劃分VLAN:
- 創(chuàng)建VLAN,確定每種業(yè)務(wù)所屬的VLAN。
- 關(guān)聯(lián)子網(wǎng)和VLAN,實(shí)現(xiàn)根據(jù)報(bào)文中的源IP地址或指定網(wǎng)段確定VLAN。
- 配置接口加入VLAN,實(shí)現(xiàn)基于子網(wǎng)的VLAN通過當(dāng)前接口。
- 使能基于子網(wǎng)劃分VLAN。
操作步驟
第一步:創(chuàng)建VLAN
在Switch上創(chuàng)建VLAN100、VLAN200和VLAN300。
<HUAWEI> system-view
[~HUAWEI] sysname Switch
[*HUAWEI] commit
[~Switch] vlan batch 100 200 300
[*Switch] commit第二步:配置接口
在Switch上配置接口10GE1/0/5、10GE1/0/6、10GE1/0/7為Hybrid類型,分別以u(píng)ntagged方式加入VLAN100、VLAN200和VLAN300。并使能基于子網(wǎng)劃分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] commit
第三步:接口劃入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] commit在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] commit在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] commit第四步:配置基于子網(wǎng)劃分VLAN
在Switch上配置VLAN100與IP地址192.168.1.2/24關(guān)聯(lián)。
[~Switch] vlan 100
[~Switch-vlan100] ip-subnet-vlan 1 ip 192.168.1.2 24
[*Switch-vlan100] quit在Switch上配置VLAN200與IP地址192.168.2.2/24關(guān)聯(lián)。
[*Switch] vlan 200
[*Switch-vlan200] ip-subnet-vlan 1 ip 192.168.2.2 24
[*Switch-vlan200] quit在Switch上配置VLAN300與IP地址192.168.3.2/24關(guān)聯(lián)。
[*Switch] vlan 300
[*Switch-vlan300] ip-subnet-vlan 1 ip 192.168.3.2 24
[*Switch-vlan300] quit
[*Switch] commit測(cè)試配置結(jié)果
在Switch上執(zhí)行以下命令,顯示信息如下:
[~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
----------------------------------------------------------------生產(chǎn)業(yè)務(wù)、辦公業(yè)務(wù)和災(zāi)備業(yè)務(wù)分別可以和生產(chǎn)中心、園區(qū)辦公網(wǎng)、災(zāi)備數(shù)據(jù)中心互相ping通,但是生產(chǎn)業(yè)務(wù)不能和園區(qū)辦公網(wǎng)、災(zāi)備數(shù)據(jù)中心ping通,辦公業(yè)務(wù)不能和生產(chǎn)中心、災(zāi)備數(shù)據(jù)中心ping通,災(zāi)備業(yè)務(wù)不能和生產(chǎn)中心、園區(qū)辦公網(wǎng)ping通。























