题目要求
1.PC1和PC3所在接口为Access接口
2.PC2/4/5/6处于同一网段,其中PC2可以访问PC4/5/6PC4可以访问PC5,但不能访问PC6PC5不能访问PC6
3.PC1/3与PC2/4/5/6不在同一网段
4.所有PC通过DHCP获取IP地址,且PC1/3可以正常访问PC2/4/5/6
题目分析
1.将交换机连接PC2/4/5/6的接口类型更改为Hybrid类型,并修改其PVID值和允许列表的参数
2.在路由器上配置子接口,并在子接口开启并配置DHCP
配置内容
R1配置:
dhcp enable ----开启DHCP功能
#
ip pool pool ----创建用来分配IP地址的地址池gateway-list 192.168.2.254 ----配置网关network 192.168.2.0 mask 255.255.255.0 ----配置下发的网段lease day 10 hour 0 minute 0 ----配置租期dns-list 4.4.4.4 ----配置DNS服务器
#
interface GigabitEthernet0/0/0ip address 192.168.2.254 255.255.255.0 dhcp select global ----在父接口处配置全局DHCP
#
interface GigabitEthernet0/0/0.1 ----创建子接口dot1q termination vid 2 ----配置子接口可以处理的VLAN标签ip address 192.168.1.1 255.255.255.0 ----配置子接口的IP地址dhcp select interface ----基于本接口进行DHCP的配置dhcp server lease day 10 hour 0 minute 0 ----配置租期dhcp server dns-list 4.4.4.4 ----配置DNS服务器
#SW1配置:
interface GigabitEthernet0/0/1port hybrid tagged vlan 2 ----在进行转发或接收到vlan2的数据帧时,打上标签port hybrid untagged vlan 3 to 6 ----在进行转发或接收到vlan3-6的数据帧时,剥离标签
#
interface GigabitEthernet0/0/2port link-type access ----将该接口的接口类型修改为access类型port default vlan 2 ----将vlan2划入该接口
#
interface GigabitEthernet0/0/3port hybrid pvid vlan 3port hybrid untagged vlan 2 to 6
#
interface GigabitEthernet0/0/4port link-type trunk ----将该接口类型修改为trunk类型port trunk allow-pass vlan 2 to 6 ----配置允许从该接口发出或接收到的vlan数据帧
#SW2配置:
interface GigabitEthernet0/0/1port link-type trunkport trunk allow-pass vlan 2 to 6
#
interface GigabitEthernet0/0/2port link-type accessport default vlan 2
#
interface GigabitEthernet0/0/3port hybrid pvid vlan 4port hybrid untagged vlan 2 to 4 6
#
interface GigabitEthernet0/0/4port link-type trunkport trunk allow-pass vlan 2 to 6
#SW3配置:
interface GigabitEthernet0/0/1port link-type trunkport trunk allow-pass vlan 2 to 6
#
interface GigabitEthernet0/0/2port hybrid pvid vlan 5port hybrid untagged vlan 2 to 3 5
#
interface GigabitEthernet0/0/3port hybrid pvid vlan 6port hybrid untagged vlan 2 to 4 6
实验结果
PC端自动获取IP地址
PC1
PC2
PC6
访问测试
PC2访问PC6
PC4访问PC5
PC5不能访问PC6