基于端口划分vlan
阅读原文时间:2023年07月09日阅读:2

拓扑图

PC ip 配置

PC 5:192.168.1.5
PC 6:192.168.1.6
PC 7:192.168.1.7
PC 8: 192.168.1.8

交换机配置

  1. 创建vlan10、vlan20

    system-view
    [Huawei]vlan 10
    [Huawei-vlan10]quit
    [Huawei]vlan 20
    [Huawei-vlan20]quit
    [Huawei]display vlan

  2. 将端口设置为access口,并划入vlan

    [Huawei]interface Ethernet 0/0/1
    [Huawei-Ethernet0/0/1]port link-type access
    [Huawei-Ethernet0/0/1]port default vlan 10
    [Huawei-Ethernet0/0/1]quit

    [Huawei]interface Ethernet 0/0/2
    [Huawei-Ethernet0/0/2]port link-type access
    [Huawei-Ethernet0/0/2]port default vlan 20
    [Huawei-Ethernet0/0/2]quit

    [Huawei]interface Ethernet 0/0/3
    [Huawei-Ethernet0/0/3]port link-type access
    [Huawei-Ethernet0/0/3]port default vlan 20
    [Huawei-Ethernet0/0/3]quit

    [Huawei]interface Ethernet 0/0/4
    [Huawei-Ethernet0/0/4]port link-type access
    [Huawei-Ethernet0/0/4]port default vlan 10
    [Huawei-Ethernet0/0/4]quit

  3. 查看vlan

    [Huawei]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/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/4(U)

    20 common UT:Eth0/0/2(U) 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

测试

  1. 相同vlan可以联通

    PC>ping 192.168.1.8

    Ping 192.168.1.8: 32 data bytes, Press Ctrl_C to break
    From 192.168.1.8: bytes=32 seq=1 ttl=128 time=31 ms
    From 192.168.1.8: bytes=32 seq=2 ttl=128 time=16 ms
    From 192.168.1.8: bytes=32 seq=3 ttl=128 time=31 ms
    From 192.168.1.8: bytes=32 seq=4 ttl=128 time=32 ms
    From 192.168.1.8: bytes=32 seq=5 ttl=128 time=47 ms

    --- 192.168.1.8 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 16/31/47 ms

  2. 不同vlan不同

    PC>ping 192.168.1.6

    Ping 192.168.1.6: 32 data bytes, Press Ctrl_C to break
    From 192.168.1.5: Destination host unreachable
    From 192.168.1.5: Destination host unreachable
    From 192.168.1.5: Destination host unreachable
    From 192.168.1.5: Destination host unreachable
    From 192.168.1.5: Destination host unreachable

    --- 192.168.1.6 ping statistics ---
    5 packet(s) transmitted
    0 packet(s) received
    100.00% packet loss

手机扫一扫

移动阅读更方便

阿里云服务器
腾讯云服务器
七牛云服务器