<HW-SW4>sys //进入系统视图
[HW-SW4]stp mode stp //生成树模式为STP
[HW-SW4]vlan batch 20 30 //建立VLAN20和30
[HW-SW4]interface g 0/0/1 //进入1口配置
[HW-SW4-GigabitEthernet0/0/1]port link-type access //端口为接入口
[HW-SW4-GigabitEthernet0/0/1]port default vlan 20 //端口VLAN标记为20
[HW-SW4-GigabitEthernet0/0/1]stp edged-port enable //端口为边缘接口
[HW-SW4-GigabitEthernet0/0/2]port link-type access //端口为接入口
[HW-SW4-GigabitEthernet0/0/2]port default vlan 30 //端口VLAN标记为30
[HW-SW4-GigabitEthernet0/0/2]stp edged-port enable //端口为边缘接口
[HW-SW4-GigabitEthernet0/0/2]int g 0/0/10 //进入10口配置
[HW-SW4-GigabitEthernet0/0/10]port link-type trunk //端口为trunk
[HW-SW4-GigabitEthernet0/0/10]port trunk allow-pass vlan all //允许所有VLAN通过
[HW-SW4]dis port vlan active //查看端口的VLAN信息
T =TAG U=UNTAG
Port Link Type PVID VLAN List
GE0/0/1 access 20 U: 20
GE0/0/2 access 30 U: 30
GE0/0/3 hybrid 1 U: 1
GE0/0/4 hybrid 1 U: 1
GE0/0/5 hybrid 1 U: 1
GE0/0/6 hybrid 1 U: 1
GE0/0/7 hybrid 1 U: 1
GE0/0/8 hybrid 1 U: 1
GE0/0/9 hybrid 1 U: 1
GE0/0/10 trunk 1 U: 1
T: 20 30
![]
===============================================
<Huawei>sys //进入系统视图
[Huawei]SYS HW-R3 //系统名称为HW-R3
[HW-R3]interface GigabitEthernet 0/0/0.20 //创建0/0/0.20的子端口
[HW-R3-GigabitEthernet0/0/0.20]dot1q termination vid 20 //该子接口接收vlan20通信
[HW-R3-GigabitEthernet0/0/0.20]ip address 10.1.20.30 27 //该端口地址为10.1.20.30
[HW-R3-GigabitEthernet0/0/0.20]interface GigabitEthernet 0/0/0.30 //创建0/0/0.30的子端口
[HW-R3-GigabitEthernet0/0/0.30]dot1q termination vid 30 //该子接口接收vlan30通信
[HW-R3-GigabitEthernet0/0/0.30]ip address 10.1.30.30 27 //该端口地址为10.1.30.30
[HW-R3]interface GigabitEthernet 0/0/0.20 //配置0/0/0.20的子端口
[HW-R3-GigabitEthernet0/0/0.20]arp broadcast enable //开启ARP广播
[HW-R3-GigabitEthernet0/0/0.20]interface GigabitEthernet 0/0/0.30 //配置0/0/0.30的子端口
[HW-R3-GigabitEthernet0/0/0.30]arp broadcast enable //开启ARP广播
==================================================
[HW-SW1]interface Vlanif 8 //配置vlangif8
[HW-SW1-Vlanif8]ip address 10.1.10.13 28 //配置IP地址
[HW-SW1-Vlanif8]int vlan 9 //配置vlangif9
[HW-SW1-Vlanif9]ip address 10.1.10.28 28 //配置IP地址
[HW-SW1-Vlanif9]int vlan 10 //配置vlangif10
[HW-SW1-Vlanif10]ip address 10.1.10.45 28 //配置IP地址
[HW-SW2]interface Vlanif 8 //配置vlangif8
[HW-SW2-Vlanif8]ip address 10.1.10.13 28 //配置IP地址
[HW-SW2-Vlanif8]int vlan 9 //配置vlangif9
[HW-SW2-Vlanif9]ip address 10.1.10.28 28 //配置IP地址
[HW-SW2-Vlanif9]int vlan 10 //配置vlangif10
[HW-SW2-Vlanif10]ip address 10.1.10.45 28 //配置IP地址