分析:
(1)PC1和PC3在VLAN2,PC2在VLAN3,PC4和PC4在VLAN4,PC6在VLAN5
(2)VLAN3可以访问VLAN4和5,VLAN4不能访问VLAN5
(创建VLAN2到5)
[sw1]vlan batch 2 to 5
(接口划入VLAN)
[sw1]int e0/0/2
[sw1-Ethernet0/0/2]port link-type access
[sw1-Ethernet0/0/2]port default vlan 2
(混杂接口,流量属于VLAN3,允许VLAN2、4和5的流量进入)
[sw1]int e0/0/3
[sw1-Ethernet0/0/3]port hybrid pvid vlan 3
[sw1-Ethernet0/0/3]port hybrid untagged vlan 3 to 5
(配置trunk干道)
[sw1]int g0/0/1
[sw1-GigabitEthernet0/0/1]port link-type trunk
[sw1-GigabitEthernet0/0/1]port trunk allow-pass vlan 2 to 5
(混杂接口)
[sw1]int g0/0/2
[sw1-GigabitEthernet0/0/2]port hybrid tagged vlan 2
[sw1-GigabitEthernet0/0/2]port hybrid untagged vlan 3 to 5
[sw2]vlan batch 2 to 5
[sw2]int e0/0/2
[sw2-Ethernet0/0/2]port link-type access
[sw2-Ethernet0/0/2]port default vlan 2
(混杂接口)
[sw2]int e0/0/3
[sw2-Ethernet0/0/3]port hybrid pvid vlan 4
[sw2-Ethernet0/0/3]port hybrid untagged vlan 3 to 4
(VLAN2访问VLAN3,4,5不是依靠VLAN之间的互访,而是依靠路由器的路由)
(配置trunk干道)
[sw2]int g0/0/2
[sw2-GigabitEthernet0/0/2]port link-type trunk
[sw2-GigabitEthernet0/0/2]port trunk allow-pass vlan 2 to 5
[sw2]int g0/0/1
[sw2-GigabitEthernet0/0/1]port hybrid tagged vlan 2 to 5
[sw3]vlan batch 2 to 5
[sw3]int e0/0/2
(混杂接口)
[sw3-Ethernet0/0/2]port hybrid pvid vlan 4
[sw3-Ethernet0/0/2]port hybrid untagged vlan 3 to 4
[sw3]int e0/0/3
[sw3-Ethernet0/0/3]port hybrid pvid vlan 5
[sw3-Ethernet0/0/3]port hybrid untagged vlan 3 5
(配置trunk干道)
[sw3]int g0/0/2
[sw3-GigabitEthernet0/0/2]port link-type trunk
[sw3-GigabitEthernet0/0/2]port trunk allow-pass vlan 2 to 5
(配置物理接口,扮演VLAN3,4,5的网关)
[r1]int g0/0/0
[r1-GigabitEthernet0/0/0]ip address 192.168.1.1 24
(虚拟接口,专属于VLAN2的网关)
[r1]int g0/0/0.1
[r1-GigabitEthernet0/0/0.1]dot1q termination vid 2
[r1-GigabitEthernet0/0/0.1]ip add 192.168.2.1 24
[r1-GigabitEthernet0/0/0.1]arp broadcast enable
(开启DHCP服务)
[r1]dhcp enable
[r1]ip pool v2
Info: It's successful to create an IP address pool.
[r1-ip-pool-v2]network 192.168.2.0 ma 24
[r1-ip-pool-v2]gateway-list 192.168.2.1
[r1-ip-pool-v2]dns-list 114.114.114.114
[r1]ip pool v3
Info: It's successful to create an IP address pool.
[r1-ip-pool-v3]network 192.168.1.0 mask 24
[r1-ip-pool-v3]gateway-list 192.168.1.1
[r1-ip-pool-v3]dns-list 114.114.114.114
[r1]int g0/0/0
[r1-GigabitEthernet0/0/0]dhcp select global
[r1]int g0/0/0.1
[r1-GigabitEthernet0/0/0.1]dhcp select global
(测试)
(全部默认允许VALN1进入)