配置图
如上图所示,为交换机的配置
复制区
sw1的配置:
[sw1]vlan batch 10 20 30 创建vlan
[sw1]int g0/0/1
[sw1-GigabitEthernet0/0/1]p l a 设置接口状态
[sw1-GigabitEthernet0/0/1]p d v 10 设置接口允许通过的vlan
[sw1-GigabitEthernet0/0/1]int g0/0/4
[sw1-GigabitEthernet0/0/4]p l a
[sw1-GigabitEthernet0/0/4]p d v 30
[sw1-GigabitEthernet0/0/4]int g0/0/3
[sw1-GigabitEthernet0/0/3]p l a
[sw1-GigabitEthernet0/0/3]p d v 20
[sw1-GigabitEthernet0/0/3]int g0/0/2
[sw1-GigabitEthernet0/0/2]p l t
[sw1-GigabitEthernet0/0/2]p t p v 30
[sw1-GigabitEthernet0/0/2]u p t a v 1 设置接口不允许通过vlan1
[sw1-GigabitEthernet0/0/2]p t a v 10 20 30
sw2的配置:
[sw 2]vlan batch 10 20 30
[sw 2]int g 0/0/2
[sw 2-GigabitEthernet0/0/2]p l t
[sw 2-GigabitEthernet0/0/2]p t p v 30
[sw 2-GigabitEthernet0/0/2]port trunk allow-pass vlan 30
[sw 2-GigabitEthernet0/0/2]undo port trunk allow-pass vlan 1
[sw 2-GigabitEthernet0/0/2]int g0/0/3
[sw 2-GigabitEthernet0/0/3]p l t
[sw 2-GigabitEthernet0/0/3]undo port trunk allow-pass vlan 1
[sw 2-GigabitEthernet0/0/3]port trunk allow-pass vlan 10 20 30
[sw 2-GigabitEthernet0/0/3]int g0/0/1
[sw 2-GigabitEthernet0/0/1]p l t
[sw 2-GigabitEthernet0/0/1]p t a v 10 20 30
[sw 2-GigabitEthernet0/0/1]p t p v 30
[sw 2-GigabitEthernet0/0/1]undo port trunk allow-pass vlan 1
sw3的配置:
[sw3]vlan 20
[sw3-vlan20]int g0/0/2
[sw3-GigabitEthernet0/0/2]p l a
[sw3-GigabitEthernet0/0/2]p d v 20
[sw3-GigabitEthernet0/0/2]int g0/0/1
[sw3-GigabitEthernet0/0/1]p l a
[sw3-GigabitEthernet0/0/1]p d v 20
sw4的配置:
[sw4]un in en
[sw4]vlan batch 10 20 30
[sw4]int g0/0/1
[sw4-GigabitEthernet0/0/1]p l h
[sw4-GigabitEthernet0/0/1]port hybrid pvid vlan 30
[sw4-GigabitEthernet0/0/1]port hybrid untagged vlan 30
[sw4-GigabitEthernet0/0/1]undo port hybrid untagged vlan 1
[sw4-GigabitEthernet0/0/1]int g0/0/2
[sw4-GigabitEthernet0/0/2]p l h
[sw4-GigabitEthernet0/0/2]p h p v 10
[sw4-GigabitEthernet0/0/2]undo port hybrid untagged vlan 1
[sw4-GigabitEthernet0/0/2]port hybrid untagged vlan 10
[sw4-GigabitEthernet0/0/2]int g 0/0/3
[sw4-GigabitEthernet0/0/3]p l h
[sw4-GigabitEthernet0/0/3]p h p v 20
[sw4-GigabitEthernet0/0/3]undo port hybrid untagged vlan 1
[sw4-GigabitEthernet0/0/3]port hybrid untagged vlan 20
[sw4-GigabitEthernet0/0/3]int g0/0/4
[sw4-GigabitEthernet0/0/4]p l h
[sw4-GigabitEthernet0/0/4]undo port hybrid untagged vlan 1
[sw4-GigabitEthernet0/0/4]port hybrid tagged vlan 10 20 30
保证pc5和pc6 互通:
[sw4]int g0/0/2
[sw4-GigabitEthernet0/0/2]port hybrid untagged vlan 20
[sw4-GigabitEthernet0/0/2]int g0/0/3
[sw4-GigabitEthernet0/0/3]port hybrid untagged vlan 10
要根据对应的数据流的方向,设置每个接口可以通过的vlan-id,是否需要标签。