【eNSP】VLAN基础配置

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

在这里插入图片描述

1、创建VLAN

LSW1

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

LSW2

[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
[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
[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
[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
[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

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

LSW2

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

2、Hybrid配置

LSW1

[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

[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、验证

[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地址

[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

[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功能

[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、验证

[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 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值