先配置交换机sw1
[sw1]vlan batch 2 to 6
[sw1-Ethernet0/0/1]port link-type access
[sw1-Ethernet0/0/1]port default vlan 2
[sw1-Ethernet0/0/2]port hybrid pvid vlan 3
[sw1-Ethernet0/0/2]port hybrid untagged vlan 3 to 6
[sw1-GigabitEthernet0/0/2]port link-type trunk
[sw1-GigabitEthernet0/0/2]port trunk allow-pass vlan all
配置交换机sw2
[sw2]vlan batch 2 to 6
[sw2-Ethernet0/0/1]port link-type access
[sw2]vlan batch 2 to 6
[sw2-Ethernet0/0/2]port hybrid pvid vlan 4
[sw2-Ethernet0/0/2]port hybrid untagged vlan 3 to 5
[sw2-GigabitEthernet0/0/1]port link-type trunk
[sw2-GigabitEthernet0/0/1]port trunk allow-pass vlan all
[sw2-GigabitEthernet0/0/2]port link-type trunk
[sw2-GigabitEthernet0/0/2]port trunk allow-pass vlan all
配置交换机sw3
[sw3]vlan batch 2 to 6
[sw3-Ethernet0/0/1]port hybrid pvid vlan 5
[sw3-Ethernet0/0/1]port hybrid untagged vlan 3 to 5
[sw3-Ethernet0/0/2]port hybrid pvid vlan 6
[sw3-Ethernet0/0/2]port hybrid untagged vlan 3 6
[sw3-GigabitEthernet0/0/2]port hybrid tagged vlan 2 to 6
完善该网络的规则
#vlan2可以带着标签访问r1
#valn3——vlan6需要脱下标签
[sw1-GigabitEthernet0/0/1]port hybrid tagged vlan 2
[sw1-GigabitEthernet0/0/1]port hybrid untagged vlan 3 to 6
#配置路由器
[r1-GigabitEthernet0/0/0]ip address 192.168.2.1 24
[r1-GigabitEthernet0/0/0.1]dot1q termination vid 2
[r1-GigabitEthernet0/0/0.1]arp broadcast enable
#配置dhcp
[r1]ip pool a
[r1-ip-pool-a]network 192.168.1.0 ma 24
[r1-ip-pool-a]gateway-list 192.168.1.1
[r1]ip pool b
[r1-ip-pool-b]network 192.168.2.0 mask 24
[r1-ip-pool-b]gateway-list 192.168.2.1
[r1-GigabitEthernet0/0/0]dhcp select global
[r1-GigabitEthernet0/0/0.1]dhcp select global
然后让所有pc端获取ip地址