VLAN的规划
VLAN配置:
命令 | 备注 |
---|---|
vlan 10 | 创建单个VLAN |
vlan batch 10 to 20 | 创建多个VLAN |
port link-type access port link-type trunk port link-type hybrid |
配置接口类型 简写为P L A、P L T、P L H |
port default vlan 10 | 配置access关联的VLAN/PVID,简写 P D V 10 |
port trunk allow-pass vlan 10 | 配置Trunk允许通过的VLAN,简写P L A V 10 华为默认只允许VLAN1 |
port trunk pvid vlan 10 | 配置Trunk的PVID |
port hybrid tagged vlan 10 port hybrid untagged vlan 10 |
配置Hybird标记VLAN(标记和剥离) |
port hybrid pvid vlan 10 | 配置Hybird的PVID |
display vlan | 验证VLAN |
display port vlan 10 | 验证VLAN |
查看VLAN dis vlan
[Huawei]display vlan
The total number of vlans is : 1
--------------------------------------------------------------------------------
U: Up; D: Down; TG: Tagged; UT: Untagged;
MP: Vlan-mapping; ST: Vlan-stacking;
#: ProtocolTransparent-vlan; *: Management-vlan;
--------------------------------------------------------------------------------
VID Type Ports
--------------------------------------------------------------------------------
1 common UT:GE0/0/1(D) GE0/0/2(D) GE0/0/3(D) GE0/0/4(D)
GE0/0/5(D) GE0/0/6(D) GE0/0/7(D) GE0/0/8(D)
GE0/0/9(D) GE0/0/10(D) GE0/0/11(D) GE0/0/12(D)
GE0/0/13(D) GE0/0/14(D) GE0/0/15(D) GE0/0/16(D)
GE0/0/17(D) GE0/0/18(D) GE0/0/19(D) GE0/0/20(D)
GE0/0/21(D) GE0/0/22(D) GE0/0/23(D) GE0/0/24(D)
VID Status Property MAC-LRN Statistics Description
--------------------------------------------------------------------------------
1 enable default enable disable VLAN 0001
[Huawei]
创建vlan 与批量创建vlan
[Huawei-vlan10]vlan 3
[Huawei-vlan3]dis this
[Huawei-vlan3]dis this
#
return
[Huawei-vlan3]
[Huawei-vlan3]vlan batch 10 to 15 20
Info: This operation may take a few seconds. Please wait for a moment...done.
[Huawei]dis
[Huawei]display vl
[Huawei]display vlan
The total number of vlans is : 9
--------------------------------------------------------------------------------
U: Up; D: Down; TG: Tagged; UT: Untagged;
MP: Vlan-mapping; ST: Vlan-stacking;
#: ProtocolTransparent-vlan; *: Management-vlan;
--------------------------------------------------------------------------------
VID Type Ports
--------------------------------------------------------------------------------
1 common UT:GE0/0/1(U) GE0/0/2(U) GE0/0/3(D) GE0/0/4(D)
GE0/0/5(D) GE0/0/6(D) GE0/0/7(D) GE0/0/8(D)
GE0/0/9(D) GE0/0/10(D) GE0/0/11(D) GE0/0/12(D)
GE0/0/13(D) GE0/0/14(D) GE0/0/15(D) GE0/0/16(D)
GE0/0/17(D) GE0/0/18(D) GE0/0/19(D) GE0/0/20(D)
GE0/0/21(D) GE0/0/22(D) GE0/0/23(D) GE0/0/24(D)
3 common
10 common
11 common
12 common
13 common
14 common
15 common
20 common
VID Status Property MAC-LRN Statistics Description
-----------------------------------------------------------------
配置接口类型
[Huawei]interface g0/0/1
[Huawei-GigabitEthernet0/0/1]port link-type access
[Huawei-GigabitEthernet0/0/1]display this
#
interface GigabitEthernet0/0/1
port link-type access
#
return
[Huawei-GigabitEthernet0/0/1]
[Huawei-GigabitEthernet0/0/1]display port vlan
Port Link Type PVID Trunk VLAN List
-------------------------------------------------------------------------------
GigabitEthernet0/0/1 access 1 -
GigabitEthernet0/0/2 hybrid 1 -
GigabitEthernet0/0/3 hybrid 1 -
GigabitEthernet0/0/4 hybrid 1 -
GigabitEthernet0/0/5 hybrid 1 -
GigabitEthernet0/0/6 hybrid 1 -
修改pvid
[Huawei-GigabitEthernet0/0/1]port default vlan 10
[Huawei-GigabitEthernet0/0/1]display port vlan
Port Link Type PVID Trunk VLAN List
-------------------------------------------------------------------------------
GigabitEthernet0/0/1 access 10 -
GigabitEthernet0/0/2 hybrid 1 -
GigabitEthernet0/0/3 hybrid 1 -
配置为trunk
[Huawei-GigabitEthernet0/0/2]port link-type trunk
[Huawei-GigabitEthernet0/0/2]display this
#
interface GigabitEthernet0/0/2
port link-type trunk
#
return
[Huawei-GigabitEthernet0/0/2]
由于二口配置完trunk后默认的pvid为1 所以加上 trunk vlan list允许vlan3 的流量 当不需要打标签的时候要修改为pvid 10
[Huawei-GigabitEthernet0/0/2]display port vlan
Port Link Type PVID Trunk VLAN List
-------------------------------------------------------------------------------
GigabitEthernet0/0/1 access 10 -
GigabitEthernet0/0/2 trunk 1 1
GigabitEthernet0/0/3 hybrid 1 -
[Huawei-GigabitEthernet0/0/2]port trunk allow-pass vlan 10
[Huawei-GigabitEthernet0/0/2]dis th
interface GigabitEthernet0/0/2
port link-type trunk
port trunk allow-pass vlan 10
#
return
[Huawei-GigabitEthernet0/0/2]
标签测试
此时交换机trunk口为pvid为1,vlan pvid为10。则在trunk口上抓包为有标签的数据包
[Huawei]display vlan
The total number of vlans is : 9
--------------------------------------------------------------------------------
U: Up; D: Down; TG: Tagged; UT: Untagged;
MP: Vlan-mapping; ST: Vlan-stacking;
#: ProtocolTransparent-vlan; *: Management-vlan;
--------------------------------------------------------------------------------
VID Type Ports
--------------------------------------------------------------------------------
1 common UT:GE0/0/2(U) GE0/0/3(D) GE0/0/4(D) GE0/0/5(D)
GE0/0/6(D) GE0/0/7(D) GE0/0/8(D) GE0/0/9(D)
GE0/0/10(D) GE0/0/11(D) GE0/0/12(D) GE0/0/13(D)
GE0/0/14(D) GE0/0/15(D) GE0/0/16(D) GE0/0/17(D)
GE0/0/18(D) GE0/0/19(D) GE0/0/20(D) GE0/0/21(D)
GE0/0/22(D) GE0/0/23(D) GE0/0/24(D)
3 common
10 common UT:GE0/0/1(U)
TG:GE0/0/2(U)
[Huawei]display port vlan
Port Link Type PVID Trunk VLAN List
-------------------------------------------------------------------------------
GigabitEthernet0/0/1 access 10 -
GigabitEthernet0/0/2 trunk 1 1 10
GigabitEthernet0/0/3 hybrid 1 -
在二口抓包
修改为pvid = 10的时候 就不会抓到带有标签的数据包
[Huawei-GigabitEthernet0/0/2]port trunk pvid vla
[Huawei-GigabitEthernet0/0/2]port trunk pvid vlan 10
[Huawei-GigabitEthernet0/0/2]display port vlan
Port Link Type PVID Trunk VLAN List
-------------------------------------------------------------------------------
GigabitEthernet0/0/1 access 10 -
GigabitEthernet0/0/2 trunk 10 1 10
GigabitEthernet0/0/3 hybrid 1 -
GigabitEthernet0/0/4 hybrid 1 -
GigabitEthernet0/0/5 hybrid 1 -
hybird标签命令
如果配置了某种接口类型,且配置了子命令的话,在切换接口类型之前需要还原到默认配置,也就是全部删除配置
interface GigabitEthernet0/0/2
port link-type trunk
port trunk pvid vlan 10
port trunk allow-pass vlan 10
#
return
[Huawei-GigabitEthernet0/0/2]port link-type hybrid
Error: Please renew the default configurations.
[Huawei-GigabitEthernet0/0/2]display this
#
interface GigabitEthernet0/0/2
port link-type trunk
port trunk pvid vlan 10
#
[Huawei-GigabitEthernet0/0/2]undo port trunk pvid vlan
[Huawei-GigabitEthernet0/0/2]display this
#
interface GigabitEthernet0/0/2
port link-type trunk
#
return
[Huawei-GigabitEthernet0/0/2]port link-type hybrid
[Huawei-GigabitEthernet0/0/2]display port vlan
Port Link Type PVID Trunk VLAN List
-------------------------------------------------------------------------------
GigabitEthernet0/0/1 access 10 -
GigabitEthernet0/0/2 hybrid 1 -
GigabitEthernet0/0/3 hybrid 1 -
GigabitEthernet0/0/4 hybrid 1 -
GigabitEthernet0/0/5 hybrid 1 -