实验需求
1. pc1和pc3所在接口为access ; pvid vlan2
2. PC2/4/5/6处于同一网段:其中pc2可以访问pc4/5/6:Pc4可以访问Pc5,不能访问pc6
3. pc5不能访问pc6
4. pc1/pc3和 PC2/4/5/6不在一个网段
5. 所有pc通过DHCP获取ip地址,且pc1/3可以正常访问PC2/4/5/6
实验拓扑
实验分析
1. 所有交换机上都要创建vlan 2 to 5
2.pc1/3连交换机的接口工作模式改为access,并匹配vlan2
3.交换机之间相连的接口有标签并放行vlan 2 to 5
4. 按照需求修改PC2/4/5/6的通行规则
5.路由器上创建子接口,启用dhcp给vlan2分配ip,物理接口给其他vlan分配ip
实验配置
1. 在所有交换机上创建vlan
[sw1]vlan batch 2 to 5
[sw2]vlan batch 2 to 5
[sw3]vlan batch 2 to 5
2.配置交换机相连的接口
sw1
[sw1]int e0/0/4
[sw1-Ethernet0/0/4] port hybrid tagged vlan 2 to 5
sw2
[sw2]int e0/0/1
[sw2-Ethernet0/0/1] port hybrid tagged vlan 2 to 5
[sw2]int e0/0/4
[sw2-Ethernet0/0/4] port hybrid tagged vlan 2 to 5
sw3
[sw3]int e0/0/1
[sw3-Ethernet0/0/1] port hybrid tagged vlan 2 to 5
3.配置交换机连PC1/3的接口
sw1
[sw1]int e0/0/2
[sw1-Ethernet0/0/2]port link-type access
[sw1-Ethernet0/0/2]port default vlan 2
sw2
[sw2]int e0/0/2
[sw2-Ethernet0/0/2]port link-type access
[sw2-Ethernet0/0/2]port default vlan 2
4.配置交换机连PC2/4/5/6的接口
连pc2
[sw1-Ethernet0/0/2]int e0/0/3
[sw1-Ethernet0/0/3]dis th
#
interface Ethernet0/0/3
port hybrid pvid vlan 3
port hybrid untagged vlan 2 to 5
#
return
连pc4
[sw2-Ethernet0/0/2]int e0/0/3
[sw2-Ethernet0/0/3]dis th
#
interface Ethernet0/0/3
port hybrid pvid vlan 4
port hybrid untagged vlan 2 3 4
#
return
连pc5
[sw3]int e0/0/2
[sw3-Ethernet0/0/2]dis th
#
interface Ethernet0/0/2
port hybrid pvid vlan 4
port hybrid untagged vlan 2 3 4
#
return
连pc6
[sw3]int e0/0/3
[sw3-Ethernet0/0/3]dis th
#
interface Ethernet0/0/3
port hybrid pvid vlan 5
port hybrid untagged vlan 2 3 5
#
return
5.配置交换机连路由器的接口
[sw1-Ethernet0/0/1]port hybrid tagged vlan 2
[sw1-Ethernet0/0/1]port hybrid untagged vlan 3 to 5
6.配置路由器
6.1创建子接口并配ip和管理vlan,以及开启arp
[r1]int g0/0/0.1
[r1-GigabitEthernet0/0/0.1]dis th
[V200R003C00]
#
interface GigabitEthernet0/0/0.1
dot1q termination vid 2
ip address 192.168.1.1 255.255.255.0
arp broadcast enable
dhcp select global
#
return
6.2配置物理接口ip,并开启接口dhcp
[r1]int g0/0/0
[r1-GigabitEthernet0/0/0]dis th
[V200R003C00]
#
interface GigabitEthernet0/0/0
ip address 192.168.2.1 255.255.255.0
dhcp select global
#
return
6.1创建dhcp池塘
[r1]ip pool v2
[r1-ip-pool-v2]dis th
[V200R003C00]
#
ip pool v2
gateway-list 192.168.1.1
network 192.168.1.0 mask 255.255.255.0
dns-list 114.114.114.114 8.8.8.8
#
return
[r1]ip pool v1
[r1-ip-pool-v1]dis th
[V200R003C00]
#
ip pool v1
gateway-list 192.168.2.1
network 192.168.2.0 mask 255.255.255.0
dns-list 114.114.114.114 8.8.8.8
#
return
7. 在pc端开启dhcp
验证
验证pc1和pc3可以访问其他pc
pc2 验证2可以访问所有pc
验证pc4和pc5不能访问 pc6
game over