一、实验需求:
1、PC1和PC3所在接口为access,属于vlan2;PC2/4/5/6处于同一网段,其中PC2可以访问PC4/5/6;但PC4可以访问PC5,不能访问PC6
2、PC5不能访问PC6
3、PC1/3与PC2/4/5/6/不在同一网段
4、所有PC通过DHCP获取IP地址,且PC1/3可以正常访问PC2/4/5/6
二、实验拓扑:
三、实验配置:
1.创建VLAN:
[sw1]vlan batch 2 to 6
[sw1-GigabitEthernet0/0/2]dis this
#
interface GigabitEthernet0/0/2
port link-type access
port default vlan 2
#
return
[sw1-GigabitEthernet0/0/3]display this
#
interface GigabitEthernet0/0/3
port hybrid pvid vlan 3
port hybrid untagged vlan 3 to 6
#
return
[sw2]vlan batch 2 to 6
[sw2-GigabitEthernet0/0/2]display this
#
interface GigabitEthernet0/0/2
port link-type access
port default vlan 2
#
return
[sw2-GigabitEthernet0/0/3]display this
#
interface GigabitEthernet0/0/3
port hybrid pvid vlan 4
port hybrid untagged vlan 3 to 5
#
return
[sw3]vlan batch 2 to 6
[sw3-GigabitEthernet0/0/2]display this
#
interface GigabitEthernet0/0/2
port hybrid pvid vlan 5
port hybrid untagged vlan 2 to 5
#
return
[sw3-GigabitEthernet0/0/3]display this
#
interface GigabitEthernet0/0/3
port hybrid pvid vlan 6
port hybrid untagged vlan 2 to 3 6
#
return
2.配置trunk:
[sw1-GigabitEthernet0/0/4]display
#
interface GigabitEthernet0/0/4
shutdown
port link-type trunk
port trunk allow-pass vlan 2 to 4094 ---注意,这里命令的后面all == 2 to 4094
#
return
[sw2-GigabitEthernet0/0/1]display this
#
interface GigabitEthernet0/0/1
port link-type trunk
port trunk allow-pass vlan 2 to 4094
#
[sw2-GigabitEthernet0/0/4]display this
#
interface GigabitEthernet0/0/4
port link-type trunk
port trunk allow-pass vlan 2 to 4094
#
return
[sw3-GigabitEthernet0/0/1]display this
#
interface GigabitEthernet0/0/1
port link-type trunk
port trunk allow-pass vlan 2 to 4094
#
return
3.在交换机和路由器R1之间配置hybird:
[sw1-GigabitEthernet0/0/1]display this
#
interface GigabitEthernet0/0/1
port hybrid tagged vlan 2
port hybrid untagged vlan 3 to 6
#
return
4.在R1上配置DHCP:
[r1]interface g 0/0/0.1
[r1-GigabitEthernet0/0/0.1]dot1q termination vid 2
[r1-GigabitEthernet0/0/0.1]ip address 192.168.1.1 24
[r1-GigabitEthernet0/0/0.1]arp broadcast enable
[r1-GigabitEthernet0/0/0.1]int g 0/0/0
[r1-GigabitEthernet0/0/0]ip address 192.168.2.1 24
[r1]dhcp enable
[r1]ip policy-based-route refresh-time
Info: The refresh time of policy-based route is 5000 ms.
[r1]ip pool aaa
Info: It's successful to create an IP address pool.
[r1-ip-pool-aaa]network 192.168.1.0 mask 24
[r1-ip-pool-aaa]gateway-list 192.168.1.1
[r1]ip pool bbb
[r1-ip-pool-bbb]network 192.168.2.0 mask 24
[r1-ip-pool-bbb]gateway-list 192.168.2.1
[r1]interface GigabitEthernet 0/0/0.1
[r1-GigabitEthernet0/0/0.1]dhcp select global
[r1-GigabitEthernet0/0/0.1]int g 0/0/0
[r1-GigabitEthernet0/0/0]dhcp select global
5.在PC上用DHCP获取地址:
其他PC设备也是同样的操作!!!
6.ping验证:
至此,我们的实验就全部符合要求了!!!