1.构图:
2.步骤:
-
添加两台s3700和一台s5700交换器,组成三层交换
-
配置pc1 to pc4 的ip/24,以及网关
如:pc1其余的参考pc1配置 -
配置三层交换机sw1
- [sw1]vlan batch 2 to 4 //定义vlan2 - vlan4
- [sw1]interface GigabitEthernet 0/0/1 // 进入g/0/01接口
- [sw1-GigabitEthernet0/0/1]port link-type trunk //设置接入接口链路类型:trunk
- [sw1-GigabitEthernet0/0/1]port trunk allow-pass vlan all // 开放所有vlan
- [sw1-GigabitEthernet0/0/1]interface GigabitEthernet 0/0/2 //同理以上
- [sw1-GigabitEthernet0/0/2]port link-type trunk
- [sw1-GigabitEthernet0/0/2]port trunk allow-pass vlan all
- [sw1-GigabitEthernet0/0/2]quit
- [sw1]interface vlanif 1 //进入三层交换,逻辑接口vlanif 1
- [sw1-Vlanif1]ip address 192.168.1.254 24 //配置ip ,以下同理
- [sw1-Vlanif1]interface vlanif 2
- [sw1-Vlanif2]ip address 192.168.2.254 24
- [sw1-Vlanif2]interface vlanif 3
- [sw1-Vlanif3]ip address 192.168.3.254 24
- [sw1-Vlanif3]interface vlanif 4
- [sw1-Vlanif4]ip address 192.168.4.254 24
4.配置二层交换机sw2
- [sw2]vlan batch 2 to 4
- [sw2]interface Ethernet 0/0/1
- [sw2-Ethernet0/0/1]port link-type trunk //sw2接口下有大于1的vlan区域,故而使用trunk来承担多个vlan
- [sw2-Ethernet0/0/1]port trunk allow-pass vlan all
- [sw2-Ethernet0/0/1]quit
- [sw2]interface Ethernet 0/0/3
- [sw2-Ethernet0/0/3]port link-type access
- [sw2-Ethernet0/0/3]port default vlan 2
5.配置二层交换机sw3
- sw3]vlan batch 3 to 4
- [sw3]interface Ethernet 0/0/1
- [sw3-Ethernet0/0/1]port link-type trunk
- [sw3-Ethernet0/0/1]port trunk allow-pass vlan all
- [sw3-Ethernet0/0/1]interface Ethernet 0/0/2
- [sw3-Ethernet0/0/2]port link-type access
- [sw3-Ethernet0/0/2]port default vlan 3
- [sw3-Ethernet0/0/2]interface Ethernet 0/0/3
- [sw3-Ethernet0/0/3]port link-type access
- [sw3-Ethernet0/0/3]port default vlan 4
6.测试
pc1 对pc2/pc3/pc4 去ping连通测试
3.总结
- 区分?交换机上接口的link-type的选择:
- access:用于承担一个valn
- trunk:用于承担多个vlan
- 不仅是路由拓扑,三层交换拓扑可以实现不同网段的访问