要求VLAN2和VLAN3之间能够互相通讯
//设置交换机VLAN
[LSW1]VLAN 2
[LSW1-vlan2]description IT
[LSW1-vlan2]VLAN 3
[LSW1-vlan3]description HR
[LSW1-vlan3]display vlan
//设置交换机端口Vlan
//单端口设置
[LSW1-vlan3]interface e0/0/1
[LSW1-Ethernet0/0/1]port link-type access
[LSW1-Ethernet0/0/1]port default vlan 2
[LSW1-Ethernet0/0/1]interface e0/0/2
[LSW1-Ethernet0/0/2]port link-type access
[LSW1-Ethernet0/0/2]port default vlan 2
[LSW1-Ethernet0/0/2]interface e0/0/3
[LSW1-Ethernet0/0/3]port lin acc
[LSW1-Ethernet0/0/3]port de vlan 3
[LSW1-Ethernet0/0/3]display vlan
//配置交换机trunk
[LSW1-Ethernet0/0/3]interface g0/0/1
[LSW1-GigabitEthernet0/0/1]port lin tr
[LSW1-GigabitEthernet0/0/1]port trunk allow vlan all
//华为路由器子接口,最大支持4096个子接口
[AR1]interface g0/0/0.?
<1-4096> GigabitEthernet interface subinterface number
//配置路由器子接口
[图片上传中...(PC配置.png-f5e275-1554604593409-0)]
[AR1]interface g0/0/0.2
[AR1-GigabitEthernet0/0/0.2]ip address 20.1.1.254 24
//指明子接口属于哪个vlan
[AR1-GigabitEthernet0/0/0.2]dot1q termination vid 2
//开启ARP广播报文
[AR1-GigabitEthernet0/0/0.2]arp broadcast enable
//g0/0/0.3的配置同上
[AR1]display ip interface brief
//将子接口的IP地址作为PC机的网关地址,即可实现跨网段通讯