1. cisco设备![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/f8870dad29d197d96d57f2d010864163.png)
1.1二层交换机配置
Switch(config)#vlan 10
Switch(config-vlan)#vlan 20
Switch(config-vlan)#int f0/1
Switch(config-if)#switch mode access
Switch(config-if)#switchport access vlan 10
Switch(config)#int f0/2
Switch(config-if)#switch mode access
Switch(config-if)#switchport access vlan 20
Switch(config)#int f0/24
Switch(config-if)#switch mode trunk
1.2路由器配置
Router(config)#int f0/0
Router(config-if)#no shutdown
Router(config)#int f0/0.10
Router(config-subif)#encapsulation dot1Q 10
Router(config-subif)#ip add 192.168.10.254 255.255.255.0
Router(config)#int f0/0.20
Router(config-subif)#encapsulation dot1Q 20
Router(config-subif)#ip add 192.168.20.254 255.255.255.0
测试:
2.华为设备配置
2.1 二层交换机配置
<SW1>system-view
[SW1]vlan batch 10 20
[SW1]int Ethernet 0/0/1
[SW1-Ethernet0/0/1]port link-type access
[SW1-Ethernet0/0/1]port default vlan 10
[SW1]int Ethernet 0/0/2
[SW1-Ethernet0/0/2]port link-type access
[SW1-Ethernet0/0/2]port default vlan 20
[SW1]int Ethernet 0/0/20
[SW1-Ethernet0/0/20]port link-type trunk
[SW1-Ethernet0/0/20]port trunk allow-pass vlan 10 20
2.2 路由器配置
<Huawei>system-view
[Huawei]sysname R1
[R1]int Ethernet 0/0/0.10
[R1-Ethernet0/0/0.10]dot1q termination vid 10
[R1-Ethernet0/0/0.10]ip address 192.168.10.254 24
[R1-Ethernet0/0/0.10]arp broadcast enable
[R1-Ethernet0/0/0.10]quit
[R1]interface Ethernet 0/0/0.20
[R1-Ethernet0/0/0.20]dot1q termination vid 20
[R1-Ethernet0/0/0.20]ip address 192.168.20.254 24
[R1-Ethernet0/0/0.20]arp broadcast enable
测试: