一、实验拓扑
二、实验需求
1、PC1和PC3所在接口为access;属于vlan 2;
PC2/PC4/PC5/PC6处于同-网段:
PC2可以访问PC4/PC5/PC6
PC4可以访问PC6; PC5不能访问PC6
2、PC1/PC3与PC2/PC4/PC5/PC6不在同网段:
3、所有PC通过DHCP获取IP地址,且pc1/pc3可以正常访问PC2/PC4/PC5/PC6;
三、实验分析
因为一个子接口对应一个vlan,所以不能将vlan 3/4/5/6划分到子接口,只能借助物理接口转发数据,则192.168.1.0/24网段(vlan 3/4/5/6)DHCP由物理接口g0/0/0接口下发,而192.168.2.0/24网段(vlan 2)由子接口g0/0/0.1下发
四、实验步骤
1、交换机
(1)LSW1
[LSW1]vlan batch 2 to 6
[LSW1-GigabitEthernet0/0/2]port link-type access
[LSW1-GigabitEthernet0/0/2]port default vlan 2
[LSW1-GigabitEthernet0/0/4]port hybrid pvid vlan 3
[LSW1-GigabitEthernet0/0/4]port hybrid untagged vlan 3 to 6
[LSW1-GigabitEthernet0/0/3]port link-type trunk
[LSW1-GigabitEthernet0/0/3]port trunk allow-pass vlan 2 to 6
[LSW1-GigabitEthernet0/0/1]port hybrid tagged vlan 2
[LSW1-GigabitEthernet0/0/1]port hybrid untagged vlan 3 to 6
(2)LSW2
[LSW2]vlan batch 2 to 6
[LSW2-GigabitEthernet0/0/3]port link-type access
[LSW2-GigabitEthernet0/0/3]port default vlan 2
[LSW2-GigabitEthernet0/0/4]port hybrid pvid vlan 4
[LSW2-GigabitEthernet0/0/4]port hybrid untagged vlan 3 to 6
[LSW2-GigabitEthernet0/0/1]port link-type trunk
[LSW2-GigabitEthernet0/0/1]port trunk allow-pass vlan 2 to 6
[LSW2-GigabitEthernet0/0/2]port link-type trunk
[LSW2-GigabitEthernet0/0/2]port trunk allow-pass vlan 2 to 6
(3)LSW3
[LSW3]vlan batch 2 to 6
[LSW3-GigabitEthernet0/0/2]port hybrid pvid vlan 5
[LSW3-GigabitEthernet0/0/2]port hybrid untagged vlan 3 4 5
[LSW3-GigabitEthernet0/0/3]port hybrid pvid vlan 6
[LSW3-GigabitEthernet0/0/3]port hybrid untagged vlan 3 4 6
[LSW3-GigabitEthernet0/0/1]port link-type trunk
[LSW3-GigabitEthernet0/0/1]port trunk allow-pass vlan 2 to 6
2、路由器
(1)创建子接口
[R1]int g0/0/0.1
[R1-GigabitEthernet0/0/0.1]dot1q termination vid 2
[R1-GigabitEthernet0/0/0.1]arp broadcast enable
[R1-GigabitEthernet0/0/0.1]ip address 192.168.2.254 24
[R1-GigabitEthernet0/0/0]ip address 192.168.1.254 24
(2)DHCP配置
[R1]ip pool aa
[R1-ip-pool-aa]network 192.168.2.0 mask 24
[R1-ip-pool-aa]gateway-list 192.168.2.254
[R1-ip-pool-aa]dns-list 8.8.8.8
[R1]int g0/0/0.1
[R1-GigabitEthernet0/0/0.1]dhcp select global
[R1]ip pool bb
[R1-ip-pool-bb]network 192.168.1.0 mask 24
[R1-ip-pool-bb]gateway-list 192.168.1.254
[R1-ip-pool-bb]dns-list 8.8.8.8
[R1]int g0/0/0
[R1-GigabitEthernet0/0/0.2]dhcp select global