VLAN的规划

image.png
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

  1. [Huawei]display vlan
  2. The total number of vlans is : 1
  3. --------------------------------------------------------------------------------
  4. U: Up; D: Down; TG: Tagged; UT: Untagged;
  5. MP: Vlan-mapping; ST: Vlan-stacking;
  6. #: ProtocolTransparent-vlan; *: Management-vlan;
  7. --------------------------------------------------------------------------------
  8. VID Type Ports
  9. --------------------------------------------------------------------------------
  10. 1 common UT:GE0/0/1(D) GE0/0/2(D) GE0/0/3(D) GE0/0/4(D)
  11. GE0/0/5(D) GE0/0/6(D) GE0/0/7(D) GE0/0/8(D)
  12. GE0/0/9(D) GE0/0/10(D) GE0/0/11(D) GE0/0/12(D)
  13. GE0/0/13(D) GE0/0/14(D) GE0/0/15(D) GE0/0/16(D)
  14. GE0/0/17(D) GE0/0/18(D) GE0/0/19(D) GE0/0/20(D)
  15. GE0/0/21(D) GE0/0/22(D) GE0/0/23(D) GE0/0/24(D)
  16. VID Status Property MAC-LRN Statistics Description
  17. --------------------------------------------------------------------------------
  18. 1 enable default enable disable VLAN 0001
  19. [Huawei]

创建vlan 与批量创建vlan

  1. [Huawei-vlan10]vlan 3
  2. [Huawei-vlan3]dis this
  3. [Huawei-vlan3]dis this
  4. #
  5. return
  6. [Huawei-vlan3]
  7. [Huawei-vlan3]vlan batch 10 to 15 20
  8. Info: This operation may take a few seconds. Please wait for a moment...done.
  9. [Huawei]dis
  10. [Huawei]display vl
  11. [Huawei]display vlan
  12. The total number of vlans is : 9
  13. --------------------------------------------------------------------------------
  14. U: Up; D: Down; TG: Tagged; UT: Untagged;
  15. MP: Vlan-mapping; ST: Vlan-stacking;
  16. #: ProtocolTransparent-vlan; *: Management-vlan;
  17. --------------------------------------------------------------------------------
  18. VID Type Ports
  19. --------------------------------------------------------------------------------
  20. 1 common UT:GE0/0/1(U) GE0/0/2(U) GE0/0/3(D) GE0/0/4(D)
  21. GE0/0/5(D) GE0/0/6(D) GE0/0/7(D) GE0/0/8(D)
  22. GE0/0/9(D) GE0/0/10(D) GE0/0/11(D) GE0/0/12(D)
  23. GE0/0/13(D) GE0/0/14(D) GE0/0/15(D) GE0/0/16(D)
  24. GE0/0/17(D) GE0/0/18(D) GE0/0/19(D) GE0/0/20(D)
  25. GE0/0/21(D) GE0/0/22(D) GE0/0/23(D) GE0/0/24(D)
  26. 3 common
  27. 10 common
  28. 11 common
  29. 12 common
  30. 13 common
  31. 14 common
  32. 15 common
  33. 20 common
  34. VID Status Property MAC-LRN Statistics Description
  35. -----------------------------------------------------------------

配置接口类型

image.png

  1. [Huawei]interface g0/0/1
  2. [Huawei-GigabitEthernet0/0/1]port link-type access
  3. [Huawei-GigabitEthernet0/0/1]display this
  4. #
  5. interface GigabitEthernet0/0/1
  6. port link-type access
  7. #
  8. return
  9. [Huawei-GigabitEthernet0/0/1]
  10. [Huawei-GigabitEthernet0/0/1]display port vlan
  11. Port Link Type PVID Trunk VLAN List
  12. -------------------------------------------------------------------------------
  13. GigabitEthernet0/0/1 access 1 -
  14. GigabitEthernet0/0/2 hybrid 1 -
  15. GigabitEthernet0/0/3 hybrid 1 -
  16. GigabitEthernet0/0/4 hybrid 1 -
  17. GigabitEthernet0/0/5 hybrid 1 -
  18. GigabitEthernet0/0/6 hybrid 1 -
  19. 修改pvid
  20. [Huawei-GigabitEthernet0/0/1]port default vlan 10
  21. [Huawei-GigabitEthernet0/0/1]display port vlan
  22. Port Link Type PVID Trunk VLAN List
  23. -------------------------------------------------------------------------------
  24. GigabitEthernet0/0/1 access 10 -
  25. GigabitEthernet0/0/2 hybrid 1 -
  26. GigabitEthernet0/0/3 hybrid 1 -

配置为trunk

image.png

  1. [Huawei-GigabitEthernet0/0/2]port link-type trunk
  2. [Huawei-GigabitEthernet0/0/2]display this
  3. #
  4. interface GigabitEthernet0/0/2
  5. port link-type trunk
  6. #
  7. return
  8. [Huawei-GigabitEthernet0/0/2]
  9. 由于二口配置完trunk后默认的pvid1 所以加上 trunk vlan list允许vlan3 的流量 当不需要打标签的时候要修改为pvid 10
  10. [Huawei-GigabitEthernet0/0/2]display port vlan
  11. Port Link Type PVID Trunk VLAN List
  12. -------------------------------------------------------------------------------
  13. GigabitEthernet0/0/1 access 10 -
  14. GigabitEthernet0/0/2 trunk 1 1
  15. GigabitEthernet0/0/3 hybrid 1 -
  16. [Huawei-GigabitEthernet0/0/2]port trunk allow-pass vlan 10
  17. [Huawei-GigabitEthernet0/0/2]dis th
  18. interface GigabitEthernet0/0/2
  19. port link-type trunk
  20. port trunk allow-pass vlan 10
  21. #
  22. return
  23. [Huawei-GigabitEthernet0/0/2]

标签测试

此时交换机trunk口为pvid为1,vlan pvid为10。则在trunk口上抓包为有标签的数据包
image.png

  1. [Huawei]display vlan
  2. The total number of vlans is : 9
  3. --------------------------------------------------------------------------------
  4. U: Up; D: Down; TG: Tagged; UT: Untagged;
  5. MP: Vlan-mapping; ST: Vlan-stacking;
  6. #: ProtocolTransparent-vlan; *: Management-vlan;
  7. --------------------------------------------------------------------------------
  8. VID Type Ports
  9. --------------------------------------------------------------------------------
  10. 1 common UT:GE0/0/2(U) GE0/0/3(D) GE0/0/4(D) GE0/0/5(D)
  11. GE0/0/6(D) GE0/0/7(D) GE0/0/8(D) GE0/0/9(D)
  12. GE0/0/10(D) GE0/0/11(D) GE0/0/12(D) GE0/0/13(D)
  13. GE0/0/14(D) GE0/0/15(D) GE0/0/16(D) GE0/0/17(D)
  14. GE0/0/18(D) GE0/0/19(D) GE0/0/20(D) GE0/0/21(D)
  15. GE0/0/22(D) GE0/0/23(D) GE0/0/24(D)
  16. 3 common
  17. 10 common UT:GE0/0/1(U)
  18. TG:GE0/0/2(U)
  19. [Huawei]display port vlan
  20. Port Link Type PVID Trunk VLAN List
  21. -------------------------------------------------------------------------------
  22. GigabitEthernet0/0/1 access 10 -
  23. GigabitEthernet0/0/2 trunk 1 1 10
  24. GigabitEthernet0/0/3 hybrid 1 -

在二口抓包
image.png
修改为pvid = 10的时候 就不会抓到带有标签的数据包

  1. [Huawei-GigabitEthernet0/0/2]port trunk pvid vla
  2. [Huawei-GigabitEthernet0/0/2]port trunk pvid vlan 10
  3. [Huawei-GigabitEthernet0/0/2]display port vlan
  4. Port Link Type PVID Trunk VLAN List
  5. -------------------------------------------------------------------------------
  6. GigabitEthernet0/0/1 access 10 -
  7. GigabitEthernet0/0/2 trunk 10 1 10
  8. GigabitEthernet0/0/3 hybrid 1 -
  9. GigabitEthernet0/0/4 hybrid 1 -
  10. GigabitEthernet0/0/5 hybrid 1 -

image.png

hybird标签命令

如果配置了某种接口类型,且配置了子命令的话,在切换接口类型之前需要还原到默认配置,也就是全部删除配置

  1. interface GigabitEthernet0/0/2
  2. port link-type trunk
  3. port trunk pvid vlan 10
  4. port trunk allow-pass vlan 10
  5. #
  6. return
  7. [Huawei-GigabitEthernet0/0/2]port link-type hybrid
  8. Error: Please renew the default configurations.
  9. [Huawei-GigabitEthernet0/0/2]display this
  10. #
  11. interface GigabitEthernet0/0/2
  12. port link-type trunk
  13. port trunk pvid vlan 10
  14. #
  15. [Huawei-GigabitEthernet0/0/2]undo port trunk pvid vlan
  16. [Huawei-GigabitEthernet0/0/2]display this
  17. #
  18. interface GigabitEthernet0/0/2
  19. port link-type trunk
  20. #
  21. return
  22. [Huawei-GigabitEthernet0/0/2]port link-type hybrid
  23. [Huawei-GigabitEthernet0/0/2]display port vlan
  24. Port Link Type PVID Trunk VLAN List
  25. -------------------------------------------------------------------------------
  26. GigabitEthernet0/0/1 access 10 -
  27. GigabitEthernet0/0/2 hybrid 1 -
  28. GigabitEthernet0/0/3 hybrid 1 -
  29. GigabitEthernet0/0/4 hybrid 1 -
  30. GigabitEthernet0/0/5 hybrid 1 -