实验思路:
- 每台交换机创建VLAN
- 将接口划分到vlan中,每台交换机中做trunk,
- 配置接口的链路模式为混杂模式
实验步骤:
- 在交换机上创建vlan
[sw1]vlan batch 2 to 6
[sw2]vlan batch 2 to 6
[sw3]vlan batch 2 to 6
- 将接口划分vlan,修改允许通过的vlan
[sw1]interface GigabitEthernet 0/0/2
[sw1-GigabitEthernet0/0/2]port default vlan 2
[sw1]interface GigabitEthernet 0/0/3
[sw1-GigabitEthernet0/0/3]port link-type hybrid
[sw1-GigabitEthernet0/0/3]port hybrid pvid vlan 3
[sw1-GigabitEthernet0/0/3]port hybrid untagged vlan 3 to 6
[sw2]interface GigabitEthernet 0/0/2
[sw2-GigabitEthernet0/0/2]port link-type access
[sw2-GigabitEthernet0/0/2]port default vlan 2
[sw2-GigabitEthernet0/0/4]port hybrid pvid vlan 4
[sw2-GigabitEthernet0/0/4]port hybrid untagged vlan 3 to 6
[sw3]interface GigabitEthernet 0/0/2
[sw3-GigabitEthernet0/0/2]port hybrid pvid vlan 5
[sw3-GigabitEthernet0/0/2]port hybrid untagged vlan 3 to 5
[sw3]interface GigabitEthernet 0/0/3
[sw3-GigabitEthernet0/0/3]port hybrid untagged vlan 3 4 6
- 配置trunk干道
[sw1]interface GigabitEthernet 0/0/4
[sw1-GigabitEthernet0/0/4]port link-type trunk
[sw1-GigabitEthernet0/0/4]port trunk allow-pass vlan 2to
[sw1-GigabitEthernet0/0/4]port trunk allow-pass vlan 2 to 6
[sw2]interface GigabitEthernet 0/0/3
[sw2-GigabitEthernet0/0/3]port link-type trunk
[sw2-GigabitEthernet0/0/3]port trunk allow-pass vlan 2 to 6
[sw3]interface GigabitEthernet 0/0/1
[sw3-GigabitEthernet0/0/1]port link-type trunk
[sw3-GigabitEthernet0/0/1]port trunk allow-pass vlan 2 to 6
- 配置路由子接口,实现vlan间路由,并开启dhcp
[r1]interface GigabitEthernet 0/0/0
[r1-GigabitEthernet0/0/0]ip address 192.168.1.1 24
[r1]interface GigabitEthernet 0/0/0.1
[r1-GigabitEthernet0/0/0.1]ip address 192.168.2.1 24
[r1-GigabitEthernet0/0/0.1]dot1q termination vid 2
[r1-GigabitEthernet0/0/0.1]arp broadcast enable
[r1]dhcp enable
[r1]ip pool aa
[r1-ip-pool-aa]network 192.168.1.0 mask 24
[r1-ip-pool-aa]gateway-list 192.168.1.1
[r1-ip-pool-aa]dns-list 114.114.114.114 8.8.8.8
[r1]ip pool bb
[r1-ip-pool-bb]network 192.168.2.0 mask 24
[r1-ip-pool-bb]gateway-list 192.168.2.1
[r1-ip-pool-bb]dns-list 114.114.114.114 8.8.8.8
[r1]interface GigabitEthernet 0/0/0
[r1-GigabitEthernet0/0/0]dhcp select global
[r1]interface GigabitEthernet 0/0/0.1
[r1-GigabitEthernet0/0/0.1]dhcp select global
测试
Pc4可以访问pc6,pc5不可以访问pc6