劃分vlan是在網絡的第幾層(網絡層協議劃分VLAN)
2023-08-02 05:19:39 1
VLAN(Virtual Local Area Network,虛擬區域網)是一種將區域網設備從邏輯上劃分成一個 個網段,從而實現虛擬工作組的數據交換技術,這種技術通過在區域網數據幀上定義擴展欄位, 來對物理網絡進行邏輯上的分割,從而限定區域網數據幀的轉發範圍,縮小廣播域。
VLAN的實現方法,可以大致劃分為六類:
基於埠劃分的VLAN基於MAC地址劃分VLAN基於網絡層協議劃分VLAN根據IP組播劃分VLAN按策略劃分VLAN按用戶定義、非用戶授權劃分VLAN基於埠劃分相信很多人都用戶,而且也是比較常用的,在生產環境中也是比較普遍的。那麼基於網絡層協議劃分又如何做呢?
實驗拓撲創建VLAN
# 在Switch上創建VLAN10、VLAN20和VLAN30。
system-view[Huawei]sysname Switch[Switch]vlan batch 10 20 30
配置接口
# 在Switch上配置接口GE0/0/1、GE0/0/2、GE0/0/3為Hybrid類型,分別以untagged方式加入VLAN10、VLAN20和VLAN30。並使能基於IP子網劃分VLAN功能。
[Switch] interface gigabitethernet 0/0/1[Switch-GigabitEthernet0/0/1] port link-type hybrid[Switch-GigabitEthernet0/0/1] port hybrid untagged vlan 10[Switch-GigabitEthernet0/0/1] ip-subnet-vlan enable[Switch-GigabitEthernet0/0/1] quit[Switch] interface gigabitethernet 0/0/2[Switch-GigabitEthernet0/0/2] port link-type hybrid[Switch-GigabitEthernet0/0/2] port hybrid untagged vlan 20[Switch-GigabitEthernet0/0/2] ip-subnet-vlan enable[Switch-GigabitEthernet0/0/2] quit[Switch] interface gigabitethernet 0/0/3[Switch-GigabitEthernet0/0/3] port link-type hybrid[Switch-GigabitEthernet0/0/3] port hybrid untagged vlan 30[Switch-GigabitEthernet0/0/3] ip-subnet-vlan enable[Switch-GigabitEthernet0/0/3] quit
配置基於IP子網劃分VLAN
在Switch上配置VLAN10與IP位址192.168.1.2/24關聯,優先級為2。
[Switch] vlan 10[Switch-vlan10] ip-subnet-vlan 1 ip 192.168.1.2 24 priority 2[Switch-vlan10] quit
在Switch上配置VLAN00與IP位址192.168.2.2/24關聯,優先級為3。
[Switch] vlan 20[Switch-vlan20] ip-subnet-vlan 1 ip 192.168.2.2 24 priority 3[Switch-vlan20] quit
在Switch上配置VLAN30與IP位址192.168.3.2/24關聯,優先級為4。
[Switch] vlan 30[Switch-vlan30] ip-subnet-vlan 1 ip 192.168.3.2 24 priority 4[Switch-vlan30] quit
驗證配置結果[Switch]display ip-subnet-vlan vlan all ---------------------------------------------------------------- Vlan Index IpAddress SubnetMask Priority ---------------------------------------------------------------- 10 1 192.168.1.2 255.255.255.0 2 20 1 192.168.2.2 255.255.255.0 3 30 1 192.168.3.2 255.255.255.0 4 ---------------------------------------------------------------- ip-subnet-vlan count: 3 total count: 3
,