一、实验拓扑
二、实验要求
1.PC1/3的接口均为access模式,且属于vlan2,在同一网段
2.PC2/4/5/6的IP地址在同一网段,与PC1/3不在同一网段
3.PC2可以访问4/5/6,PC4不能访问5/6,PC5不能访问PC6
4.所有PC通过DHCP获取IP地址,PC1/3可以访问PC2/4/5/6
三、实验步骤
1.ip和vlan规划
2.在sw1和sw2上创建vlan2-6
[sw1]vlan batch 2 to 6
[sw2]vlan batch 2 to 6
3.将PC1 PC3所在接口配置为access,PVID为vlan 2
[SW1]int eth 0/0/2
[SW1-Ethernet0/0/2]port link-type access
[SW1-Ethernet0/0/2]port default vlan 2
[SW1-Ethernet0/0/2]int eth 0/0/4
[SW1-Ethernet0/0/4]port link-type access
[SW1-Ethernet0/0/4]port default vlan 2
4.配置sw1
[sw1]interface e0/0/6
[sw1-Ethernet0/0/6]port link-type trunk
[sw1-Ethernet0/0/6]port trunk allow-pass vlan 2 to 6
[sw1-Ethernet0/0/6]int e0/0/3
[sw1-Ethernet0/0/3]port hybrid pvid vlan 3
[sw1-Ethernet0/0/3]port hybrid untagged vlan 3 to 6
[sw1-Ethernet0/0/3]int e0/0/5
[sw1-Ethernet0/0/5]port hybrid pvid vlan 4
[sw1-Ethernet0/0/5]port hybrid untagged vlan 3 4
[sw1-Ethernet0/0/5]int e0/0/1
[sw1-Ethernet0/0/1]port hybrid untagged vlan 3 to 6
[sw1-Ethernet0/0/1]port hybrid tagged vlan 2
5.配置sw2
[sw2]int e0/0/3
[sw2-Ethernet0/0/3]port link-type trunk
[sw2-Ethernet0/0/3]port trunk allow-pass vlan 2 to 6
[sw2]int e0/0/1
[sw2-Ethernet0/0/1]port hybrid pvid vlan 5
[sw2-Ethernet0/0/1]port hybrid untagged vlan 3 to 5
[sw2-Ethernet0/0/1]int e0/0/2
[sw2-Ethernet0/0/2]port hybrid pvid vlan 6
[sw2-Ethernet0/0/2]port hybrid untagged vlan 3 6
6.查看vlan接口
7.路由器配置
[r1]int g0/0/1
[r1-GigabitEthernet0/0/1]int g0/0/0
[r1-GigabitEthernet0/0/0]ip add 192.168.2.1 24
[r1-GigabitEthernet0/0/0]int g0/0/0.1
[r1-GigabitEthernet0/0/0.1]dot1q termination vid 2
[r1-GigabitEthernet0/0/0.1]ip add 192.168.1.1 24
[r1]dhcp enable
[r1]ip pool v2
[r1-ip-pool-v2]network 192.168.1.0 mask 24
[r1-ip-pool-v2]gateway-list 192.168.1.1
[r1-ip-pool-v2]q
[r1]ip pool v3-6
[r1-ip-pool-v3-6]network 192.168.2.0 mask 24
[r1-ip-pool-v3-6]gateway-list 192.168.2.1
[r1-ip-pool-v3-6]q
[r1]int g0/0/0
[r1-GigabitEthernet0/0/0]dhcp select global
[r1-GigabitEthernet0/0/0]int g0/0/0.1
[r1-GigabitEthernet0/0/0.1]dhcp select global
8.
pc1 ping pc2
PC2可以访问4/5/6
PC4不能访问5/6
PC5不能访问PC6