(1)概念
子接口(Sub-Interface)是基于路由器以太网接口所创建的逻辑接口,以物理接口ID+子接口ID进行标识,子接口同物理接口一样可进行三层转发。
子接口不同于路由器的物理接口,可以终结携带VLAN Tag的数据帧。
基于一个物理接口创建多个子接口,将该物理接口对接到交换机的Trunk接口,即可实现使用一个物理接口为多个VLAN提供三层转发服务。
(2)子接口处理流程

(3)实验top

配置好PC1和PC2
S1的配置
<Huawei>system-view
[Huawei]sysname S1
[S1]vlan batch 10 20
[S1]port-group 1
[S1-port-group-1]group-member GigabitEthernet 0/0/1 to GigabitEthernet 0/0/2
[S1-port-group-1]port link-type access
[S1-port-group-1]q
[S1]interface GigabitEthernet 0/0/1
[S1-GigabitEthernet0/0/1]port default vlan 10
[S1-GigabitEthernet0/0/1]interface GigabitEthernet 0/0/2
[S1-GigabitEthernet0/0/2]port default vlan 20
[S1-GigabitEthernet0/0/2]q
[S1]interface GigabitEthernet 0/0/3
[S1-GigabitEthernet0/0/3]port link-type trunk
[S1-GigabitEthernet0/0/3]port trunk allow-pass vlan all
[S1-GigabitEthernet0/0/3]q
[S1]q
<S1>save
The current configuration will be written to the device.
Are you sure to continue?[Y/N]y
Info: Please input the file name ( *.cfg, *.zip ) [vrpcfg.zip]:
Sep 14 2026 22:26:37-08:00 S1 %%01CFM/4/SAVE(l)[53]:The user chose Y when decidi
ng whether to save the configuration to the device.
Now saving the current configuration to the slot 0.
Save the configuration successfully.
AR1的配置
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname AR1
[AR1]interface GigabitEthernet 0/0/0.10
interface interface-type interface-number.sub-interface-number,该命令用来创建子接口,interface number代表物理接口的逻辑接口通道,一般情况下,子接口ID与所要终结的VLAN ID相同。
[AR1-GigabitEthernet0/0/0.10]dot1q termination vid 10
dot1q termination vid,该命令用来配置子接口dot1q终结的单层VLAN ID,默认情况下,子接口没有配置dot1q终结的单层VLAN ID。
[AR1-GigabitEthernet0/0/0.10]ip address 192.168.10.1 24
[AR1-GigabitEthernet0/0/0.10]arp broadcast enable
arp broadcast enable,该命令用来使能终结子接口的ARP广播功能。默认情况下,终结子接口没有使能ARP广播功能。如果没有启用,子接口就不能接收广播报文,就会直接丢弃。
[AR1-GigabitEthernet0/0/0.10]q
[AR1]interface GigabitEthernet 0/0/0.20
[AR1-GigabitEthernet0/0/0.20]dot1q termination vid 20
[AR1-GigabitEthernet0/0/0.20]ip address 192.168.20.1 24
[AR1-GigabitEthernet0/0/0.20]arp broadcast enable
[AR1-GigabitEthernet0/0/0.20]q
[AR1]q
<AR1>save
The current configuration will be written to the device.
Are you sure to continue? (y/n)[n]:y
It will take several minutes to save configuration file, please wait…….
Configuration file had been saved successfully
Note: The configuration file will take effect after being activated
测试PC1 ping PC2

