如何快速查看所有接口的接口类型和缺省VLAN?
可通过命令display port vlan查看到设备上所有接口的接口类型和缺省VLAN。例如:
-
V200R005及后续版本 <HUAWEI> display port vlan Port Link Type PVID Trunk VLAN List ------------------------------------------------------------------------------- Eth-Trunk2 auto 1 1-4094 Eth-Trunk3 hybrid 1 - Eth-Trunk5 auto 1 1-4094 Ethernet0/0/1 auto 1 1-4094 Ethernet0/0/2 auto 1 1-4094 Ethernet0/0/3 auto 1 1-4094 Ethernet0/0/4 auto 1 1-4094 Ethernet0/0/5 auto 1 1-4094 Ethernet0/0/6 auto 0 - Ethernet0/0/7 auto 1 1-4094 Ethernet0/0/8 auto 0 - Ethernet0/0/9 auto 0 - Ethernet0/0/10 auto 1 1-4094 Ethernet0/0/11 auto 1 1-4094 Ethernet0/0/12 auto 0 - Ethernet0/0/13 auto 1 1-4094 Ethernet0/0/14 auto 1 1-4094 Ethernet0/0/15 auto 1 1-4094 Ethernet0/0/16 auto 1 1-4094 Ethernet0/0/17 auto 1 1-4094 Ethernet0/0/18 auto 1 1-4094 Ethernet0/0/19 auto 1 1-4094 Ethernet0/0/20 auto 1 1-4094 Ethernet0/0/21 access 20 - Ethernet0/0/22 auto 1 1-4094 Ethernet0/0/23 auto 1 1-4094 Ethernet0/0/24 access 4094 - GigabitEthernet0/0/1 auto 0 - GigabitEthernet0/0/2 auto 1 1-4094 GigabitEthernet0/0/3 auto 1 1-4094 GigabitEthernet0/0/4 auto 1 1-4094 V200R005(不包括V200R005版本)以前版本 <HUAWEI> display port vlan Port Link Type PVID Trunk VLAN List ------------------------------------------------------------------------------- GigabitEthernet0/0/1 trunk 1 1 GigabitEthernet0/0/2 hybrid 1 - GigabitEthernet0/0/3 hybrid 1 - GigabitEthernet0/0/4 hybrid 1 - GigabitEthernet0/0/5 access 10 - GigabitEthernet0/0/6 hybrid 1 - GigabitEthernet0/0/7 hybrid 1 - GigabitEthernet0/0/8 hybrid 1 - GigabitEthernet0/0/9 hybrid 1 - GigabitEthernet0/0/10 hybrid 1 - GigabitEthernet0/0/11 hybrid 1 - GigabitEthernet0/0/12 hybrid 1 - GigabitEthernet0/0/13 hybrid 1 - GigabitEthernet0/0/15 hybrid 1 - GigabitEthernet0/0/16 hybrid 1 - GigabitEthernet0/0/17 hybrid 1 - GigabitEthernet0/0/18 hybrid 1 - GigabitEthernet0/0/19 hybrid 1 - GigabitEthernet0/0/20 hybrid 1 - GigabitEthernet0/0/21 hybrid 1 - GigabitEthernet0/0/22 hybrid 1 - GigabitEthernet0/0/23 hybrid 1 - GigabitEthernet0/0/24 hybrid 1 -
其中,Link Type表示接口的接口类型,PVID表示接口上的缺省VLAN,Trunk VLAN List表示Trunk接口上允许通过的VLAN列表。如果接口没有加入任何VLAN,该处显示“-”;如果接口类型是动态协商类型(negotiation-desirable或negotiation-auto),该处显示“1-4094”。
同一VLAN能否配置多个网段?
在VLANIF接口下配置主从IP地址,可以实现同一VLAN多个网段用户间的互通。
例如,如图1所示,某VLAN10内两个主机Host_1和Host_2分别属于网段10.1.1.1/24和10.1.2.1/24,要求两主机互通。
可以在Switch上进行如下配置:
[Switch] interface gigabitethernet 0/0/1
[Switch-GigabitEthernet0/0/1] port link-type access
[Switch-GigabitEthernet0/0/1] port default vlan 10
[Switch-GigabitEthernet0/0/1] quit
[Switch] interface gigabitethernet 0/0/2
[Switch-GigabitEthernet0/0/2] port link-type access
[Switch-GigabitEthernet0/0/2] port default vlan 10
[Switch-GigabitEthernet0/0/2] quit
[Switch] interface vlanif 10
[Switch-Vlanif10] ip address 10.1.1.1 24
[Switch-Vlanif10] ip address 10.1.2.1 24 sub
[Switch-Vlanif10] quit
这样配置后,主机Host_1和Host_2间就可以互通了。
如何修改接口的链路类型?
接口的链路类型总共有4种,分别为:Access、Trunk、Hybrid、QinQ。不同版本,接口类型的修改方法不同。
- V200R005及后续版本:直接执行命令port link-type { access | trunk | hybrid | dot1q-tunnel },然后根据提示输入“y”或“n”。当接口上VLAN的配置为缺省配置时,不会出现提示信息,会直接修改链路类型。
- 若输入“y”后回车,设备会自动删除接口上VLAN的非默认配置,然后设置接口的链路类型为指定的类型。
- 若输入“n”后回车,设备不做任何处理,保持当前的链路类型和接口上的VLAN配置不变。
<HUAWEI> system-view [HUAWEI] interface gigabitethernet0/0/1 [HUAWEI-GigabitEthernet0/0/1] port link-type hybrid Warning: This command will delete VLANs on this port. Continue?[Y/N]:y Info: This operation may take a few seconds. Please wait for a moment...done.
- V200R005以前版本:当接口上VLAN的缺省配置为默认加入VLAN 1,并且PVID为VLAN 1,可以执行命令port link-type { access | trunk | hybrid | dot1q-tunnel },修改接口类型。
-
将接口类型修改为Access
<HUAWEI> system-view [HUAWEI] interface gigabitethernet0/0/1 [HUAWEI-GigabitEthernet0/0/1] port link-type access [HUAWEI-GigabitEthernet0/0/1] port default vlan 10 //设置接口的PVID为VLAN 10,并同时将VLAN 10加入接口
-
将接口类型修改为Trunk
<HUAWEI> system-view [HUAWEI] interface gigabitethernet0/0/1 [HUAWEI-GigabitEthernet0/0/1] port link-type trunk [HUAWEI-GigabitEthernet0/0/1] port trunk pvid vlan 10 //设置接口的PVID为VLAN 10 [HUAWEI-GigabitEthernet0/0/1] port trunk allow-pass vlan 2 10 20 //将VLAN 2、VLAN 10和VLAN 20加入接口
-
将接口类型修改为Hybrid
<HUAWEI> system-view [HUAWEI] interface gigabitethernet0/0/1 [HUAWEI-GigabitEthernet0/0/1] port link-type hybrid [HUAWEI-GigabitEthernet0/0/1] port hybrid pvid vlan 10 //设置接口的PVID为VLAN 10 [HUAWEI-GigabitEthernet0/0/1] port hybrid untagged vlan 2 10 //将接口以Untagged方式加入VLAN 2和VLAN 10 [HUAWEI-GigabitEthernet0/0/1] port hybrid tagged vlan 20 //将接口以Tag方式加入VLAN 20
-
将接口类型修改为QinQ
<HUAWEI> system-view [HUAWEI] interface gigabitethernet0/0/1 [HUAWEI-GigabitEthernet0/0/1] port link-type dot1q-tunnel [HUAWEI-GigabitEthernet0/0/1] port default vlan 10 //设置接口的PVID为VLAN 10,对该接口收到的所有数据报文统一封装一层VLAN为10的Tag
在修改链路类型时,如果接口上VLAN的配置不是缺省值,会出现以下提示信息:Error: Please renew the default configurations.
此时需要先把接口上VLAN的配置恢复为缺省值,然后再修改链路类型。
-
恢复Access或QinQ接口上VLAN的缺省配置 <HUAWEI> system-view [HUAWEI] interface gigabitethernet0/0/1 [HUAWEI-GigabitEthernet0/0/1] undo port default vlan 恢复Trunk接口上VLAN的缺省配置 <HUAWEI> system-view [HUAWEI] interface gigabitethernet0/0/1 [HUAWEI-GigabitEthernet0/0/1] undo port trunk pvid vlan [HUAWEI-GigabitEthernet0/0/1] undo port trunk allow-pass vlan all [HUAWEI-GigabitEthernet0/0/1] port trunk allow-pass vlan 1 恢复Hybrid接口上VLAN的缺省配置 <HUAWEI> system-view [HUAWEI] interface gigabitethernet0/0/1 [HUAWEI-GigabitEthernet0/0/1] undo port hybrid pvid vlan [HUAWEI-GigabitEthernet0/0/1] undo port hybrid vlan all [HUAWEI-GigabitEthernet0/0/1] port hybrid untagged vlan 1
-