拓扑图如下:
SW-1配置命令如下:
system-view //进系统视图
[Huawei]sysname SW-1 //修改主机名
[SW-1]vlan batch 10 20 //创建vlan 10 20
[SW-1]interface e0/0/1 //进接口
[SW-1-Ethernet0/0/1]port link-type access //配置工作模式为access
[SW-1-Ethernet0/0/1]port default vlan 10 //将e0/0/1接口加入到vlan10里
[SW-1-Ethernet0/0/1]int e0/0/2 //切换接口
[SW-1-Ethernet0/0/2]port link-type access //配置工作模式为access
[SW-1-Ethernet0/0/2]port default vlan 20 //将e0/0/2接口加入到vlan20里
[SW-1-Ethernet0/0/2]int g0/0/1 //切换接口
[SW-1-GigabitEthernet0/0/1]port link-type trunk //配置工作模式为Trunk模式
[SW-1-GigabitEthernet0/0/1]port trunk allow-pass vlan all //让所有vlan通过此接口
AR-1配置命令如下:
system-view //进系统视图
[Huawei]sysname AR-1 //修改主机名AR-1
[AR-1]int g0/0/1.1 //进子接口
[AR-1-GigabitEthernet0/0/1.1]dot1q termination vid 10 //dot1q封装,对应所属vlan 10
[AR-1-GigabitEthernet0/0/1.1]ip address 192.168.10.254 24 //配置IP地址和子网掩码
[AR-1-GigabitEthernet0/0/1.1]arp broadcast enable //开启arp广播
[AR-1-GigabitEthernet0/0/1.1]dis th //查看接口配置了什么
[V200R003C00]
#
interface GigabitEthernet0/0/1.1
dot1q termination vid 10
ip address 192.168.10.254 255.255.255.0
arp broadcast enable
#
return
[AR-1-GigabitEthernet0/0/1.1]int g0/0/1.2 //切换接口
[AR-1-GigabitEthernet0/0/1.2]dot1q termination vid 20 //dot1q封装,对应所属vlan 20
[AR-1-GigabitEthernet0/0/1.2]ip address 192.168.20.254 24 //配置IP地址和子网掩码
[AR-1-GigabitEthernet0/0/1.2]arp broadcast enable //开启arp广播
[AR-1-GigabitEthernet0/0/1.2]dis th //查看接口配置了什么
[V200R003C00]
#
interface GigabitEthernet0/0/1.2
dot1q termination vid 20
ip address 192.168.20.254 255.255.255.0
arp broadcast enable
#
return
========================================================================================