【eNSP】VLAN基础配置

一、基于接口划分VLAN(Access接口和Trunk接口)

1、创建VLAN

LSW1

ini 复制代码
[LSW1]vlan batch 10 20
Info: This operation may take a few seconds. Please wait for a moment...done.

LSW2

ini 复制代码
[LSW2]vlan batch 10 20
Info: This operation may take a few seconds. Please wait for a moment...done.

2、配置Access接口和Trunk接口

(1)配置Trunk接口

LSW1
ini 复制代码
[LSW1]interface Ethernet 0/0/1
[LSW1-Ethernet0/0/1]port link-type trunk                 # 将该接口设置为trunk链路类型,可以传输多个VLAN的数据。
[LSW1-Ethernet0/0/1]port trunk pvid vlan 1               # 将该接口的Native VLAN设置为VLAN 1,该接口上接收到的未打上VLAN标签的数据将被认为属于VLAN 1。
[LSW1-Ethernet0/0/1]port trunk allow-pass vlan 10 20     # 允许该接口通过的VLAN列表为VLAN 10和VLAN 20,只有这两个VLAN的数据可以通过该接口传输。
LSW2
ini 复制代码
[LSW2]interface Ethernet 0/0/1
[LSW2-Ethernet0/0/1]port link-type trunk
[LSW2-Ethernet0/0/1]port trunk pvid vlan 1
[LSW2-Ethernet0/0/1]port trunk allow-pass vlan 10 20

(2)配置Access接口

LSW1
ini 复制代码
[LSW1-Ethernet0/0/1]interface Ethernet 0/0/2
[LSW1-Ethernet0/0/2]port link-type access     # 将该接口设置为access链路类型,只能传输单个VLAN的数据。
[LSW1-Ethernet0/0/2]port default vlan 10      # 将该接口的默认VLAN设置为VLAN 10,该接口上接收到的未打上VLAN标签的数据将被认为属于VLAN 10。
[LSW1-Ethernet0/0/2]interface Ethernet 0/0/3
[LSW1-Ethernet0/0/3]port link-type access
[LSW1-Ethernet0/0/3]port default vlan 20
LSW2
ini 复制代码
[LSW2-Ethernet0/0/1]interface Ethernet 0/0/2
[LSW2-Ethernet0/0/2]port link-type access
[LSW2-Ethernet0/0/2]port default vlan 20
[LSW2-Ethernet0/0/2]interface Ethernet 0/0/3
[LSW2-Ethernet0/0/3]port link-type access
[LSW2-Ethernet0/0/3]port default vlan 10

二、基于接口划分VLAN(Hybrid接口)

1、创建VLAN

LSW1

ini 复制代码
[LSW1]vlan batch 10 20 100
Info: This operation may take a few seconds. Please wait for a moment...done.

LSW2

ini 复制代码
[LSW2]vlan batch 10 20 100
Info: This operation may take a few seconds. Please wait for a moment...done.

2、Hybrid配置

LSW1

ini 复制代码
[LSW1]interface Ethernet 0/0/2
[LSW1-Ethernet0/0/2]port link-type hybrid                # 将该接口设置为hybrid链路类型,可以同时传输 tagged 和 untagged 的数据。
[LSW1-Ethernet0/0/2]port hybrid pvid vlan 10             # 将该接口的Native VLAN设置为VLAN 10,即该接口上接收到的未打上VLAN标签的数据将被认为属于VLAN 10。
[LSW1-Ethernet0/0/2]port hybrid untagged vlan 10 100     # 将该接口设置为untagged模式,该接口上接收到的数据将被自动打上VLAN 10和VLAN 100的标签。
[LSW1-Ethernet0/0/2]interface Ethernet 0/0/3
[LSW1-Ethernet0/0/3]port link-type hybrid 	
[LSW1-Ethernet0/0/3]port hybrid pvid vlan 20
[LSW1-Ethernet0/0/3]port hybrid untagged vlan 20 100
[LSW1-Ethernet0/0/3]interface Ethernet 0/0/1
[LSW1-Ethernet0/0/1]port link-type hybrid
[LSW1-Ethernet0/0/1]port hybrid tagged vlan 10 20 100    # 接口的标记VLAN为VLAN 10、VLAN 20和VLAN 100。

LSW2

ini 复制代码
[LSW2]interface Ethernet 0/0/1	
[LSW2-Ethernet0/0/1]port link-type hybrid 	
[LSW2-Ethernet0/0/1]port hybrid tagged vlan 10 20 100
[LSW2-Ethernet0/0/1]interface Ethernet 0/0/2	
[LSW2-Ethernet0/0/2]port link-type hybrid 
[LSW2-Ethernet0/0/2]port hybrid pvid vlan 100
[LSW2-Ethernet0/0/2]port hybrid untagged vlan 10 20 100

3、验证

ini 复制代码
[LSW1]display vlan
The total number of vlans is : 4
--------------------------------------------------------------------------------
U: Up;         D: Down;         TG: Tagged;         UT: Untagged;
MP: Vlan-mapping;               ST: Vlan-stacking;
#: ProtocolTransparent-vlan;    *: Management-vlan;
--------------------------------------------------------------------------------

VID  Type    Ports                                                          
--------------------------------------------------------------------------------
1    common  UT:Eth0/0/1(U)     Eth0/0/2(U)     Eth0/0/3(U)     Eth0/0/4(D)     
                Eth0/0/5(D)     Eth0/0/6(D)     Eth0/0/7(D)     Eth0/0/8(D)     
                Eth0/0/9(D)     Eth0/0/10(D)    Eth0/0/11(D)    Eth0/0/12(D)    
                Eth0/0/13(D)    Eth0/0/14(D)    Eth0/0/15(D)    Eth0/0/16(D)    
                Eth0/0/17(D)    Eth0/0/18(D)    Eth0/0/19(D)    Eth0/0/20(D)    
                Eth0/0/21(D)    Eth0/0/22(D)    GE0/0/1(D)      GE0/0/2(D)      

10   common  UT:Eth0/0/2(U)                                                     
             TG:Eth0/0/1(U)                                                     

20   common  UT:Eth0/0/3(U)                                                     

             TG:Eth0/0/1(U)                                                     

100  common  UT:Eth0/0/2(U)     Eth0/0/3(U)                                     

             TG:Eth0/0/1(U)                                                     


VID  Status  Property      MAC-LRN Statistics Description      
--------------------------------------------------------------------------------

1    enable  default       enable  disable    VLAN 0001                         
10   enable  default       enable  disable    VLAN 0010                         
20   enable  default       enable  disable    VLAN 0020                         
100  enable  default       enable  disable    VLAN 0100                         
[LSW1]

三、基于MAC地址划分VLAN

1、创建VLAN并管理MAC地址

ini 复制代码
[LSW1]vlan 10
[LSW1-vlan10]
[LSW1-vlan10]mac-vlan mac-address 5489-9867-42FE     # 将MAC地址5489-9867-42FE添加到VLAN 10中。
[LSW1-vlan10]mac-vlan mac-address 5489-9861-0375
[LSW1-vlan10]q
[LSW1]vlan 20
[LSW1-vlan20]mac-vlan mac-address 5489-9810-68BE

2、加入VLAN

ini 复制代码
[LSW1]interface Ethernet 0/0/1
[LSW1-Ethernet0/0/1]port link-type hybrid 
[LSW1-Ethernet0/0/1]port hybrid untagged vlan 10
[LSW1-Ethernet0/0/1]interface Ethernet 0/0/2
[LSW1-Ethernet0/0/2]port hybrid untagged vlan 10
[LSW1-Ethernet0/0/2]q
[LSW1]interface Ethernet 0/0/3
[LSW1-Ethernet0/0/3]port link-type hybrid 
[LSW1-Ethernet0/0/3]port hybrid untagged vlan 20

3、开启基于MAC地址划分VLAN功能

ini 复制代码
[LSW1]interface Ethernet 0/0/1
[LSW1-Ethernet0/0/1]mac-vlan enable
Info: This operation may take a few seconds. Please wait for a moment...done.
[LSW1-Ethernet0/0/1]interface Ethernet 0/0/2
[LSW1-Ethernet0/0/2]mac-vlan enable
Info: This operation may take a few seconds. Please wait for a moment...done.
[LSW1-Ethernet0/0/2]interface Ethernet 0/0/3
[LSW1-Ethernet0/0/3]mac-vlan enable
Info: This operation may take a few seconds. Please wait for a moment...done.

4、验证

ini 复制代码
[LSW1]display vlan
The total number of vlans is : 3
--------------------------------------------------------------------------------
U: Up;         D: Down;         TG: Tagged;         UT: Untagged;
MP: Vlan-mapping;               ST: Vlan-stacking;
#: ProtocolTransparent-vlan;    *: Management-vlan;
--------------------------------------------------------------------------------

VID  Type    Ports                                                          
--------------------------------------------------------------------------------
1    common  UT:Eth0/0/1(U)     Eth0/0/2(U)     Eth0/0/3(U)     Eth0/0/4(D)     
                Eth0/0/5(D)     Eth0/0/6(D)     Eth0/0/7(D)     Eth0/0/8(D)     
                Eth0/0/9(D)     Eth0/0/10(D)    Eth0/0/11(D)    Eth0/0/12(D)    
                Eth0/0/13(D)    Eth0/0/14(D)    Eth0/0/15(D)    Eth0/0/16(D)    
                Eth0/0/17(D)    Eth0/0/18(D)    Eth0/0/19(D)    Eth0/0/20(D)    
                Eth0/0/21(D)    Eth0/0/22(D)    GE0/0/1(D)      GE0/0/2(D)      

10   common  UT:Eth0/0/1(U)     Eth0/0/2(U)                                     

20   common  UT:Eth0/0/3(U)                                                     


VID  Status  Property      MAC-LRN Statistics Description      
--------------------------------------------------------------------------------

1    enable  default       enable  disable    VLAN 0001                         
10   enable  default       enable  disable    VLAN 0010                         
20   enable  default       enable  disable    VLAN 0020                         

[LSW1]display mac-vlan mac-address all
---------------------------------------------------
MAC Address     MASK            VLAN    Priority   
---------------------------------------------------
5489-9861-0375  ffff-ffff-ffff  10      0          
5489-9810-68be  ffff-ffff-ffff  20      0          
5489-9867-42fe  ffff-ffff-ffff  10      0          

Total MAC VLAN address count: 3 
相关推荐
dessler5 分钟前
代理服务器-LVS的DR模式
linux·运维·云计算
知之则吱吱1 小时前
亚马逊AWS云服务器高效使用指南:最大限度降低成本的实战策略
服务器·云计算·aws
cui_win1 小时前
每日一令:Linux 极简通关指南 - 汇总
linux·运维·服务器
狐571 小时前
2025-06-02-IP 地址规划及案例分析
网络·网络协议·tcp/ip
知星小度S2 小时前
Linux权限探秘:驾驭权限模型,筑牢系统安全
linux·运维·服务器
黎茗Dawn2 小时前
5.子网划分及分片相关计算
网络·智能路由器
恰薯条的屑海鸥2 小时前
零基础在实践中学习网络安全-皮卡丘靶场(第十四期-XXE模块)
网络·学习·安全·web安全·渗透测试
科技小E2 小时前
口罩佩戴检测算法AI智能分析网关V4工厂/工业等多场景守护公共卫生安全
网络·人工智能
御承扬2 小时前
从零开始开发纯血鸿蒙应用之网络检测
网络·华为·harmonyos
Kaede65 小时前
如何应对Linux云服务器磁盘空间不足的情况
linux·运维·服务器