一、拓扑图
二、基础配置步骤
1.交换机基础配置
(1)SW1配置
[SW1] vlan batch 2 10 20 //建立vlan 2、10、20
[SW1] interface Vlanif 2 //进入vlan 2
[SW1-Vlanif10] ip address 10.1.1.1 24 //配置vlan 2的网关,一般用于交换机管理地址
[SW1] interface GigabitEthernet 0/0/1 //进入1接口
[SW1-GigabitEthernet0/0/1] port link-type trunk //配置1接口为trunk(新手说明:trunk允许多个vlan通过,access只允许一个vlan通过)
[SW1-GigabitEthernet0/0/1] port trunk allow-pass vlan all //允许1接口通过的vlan为所有
[SW1]# interface GigabitEthernet 0/0/2
[SW1-GigabitEthernet0/0/2] port link-type trunk
[SW1-GigabitEthernet0/0/2] port trunk allow-pass vlan all
(2)SW2配置
[SW2] vlan batch 2 10 20 //建立vlan 2、10、20
[SW2] interface Vlanif 2 //进入vlan 2
[SW2-Vlanif10] ip address 10.1.1.2 24 //配置vlan 2的网关,一般用于交换机管理地址
[SW2] interface GigabitEthernet 0/0/1 //进入1接口
[SW2-GigabitEthernet0/0/1] port link-type trunk //配置1接口为trunk
[SW2-GigabitEthernet0/0/1] port trunk allow-pass vlan all //允许1接口通过的vlan为所有
[SW2]# interface GigabitEthernet 0/0/2
[SW2-GigabitEthernet0/0/2] port link-type trunk
[SW2-GigabitEthernet0/0/2] port trunk allow-pass vlan all
(3)SW3配置
[SW3] vlan batch 2 10 //建立vlan 2、10
[SW3] interface Vlanif 2 //进入vlan 2
[SW3-Vlanif10] ip address 10.1.1.3 24 //配置vlan 2的网关,一般用于交换机管理地址
[SW3] interface Ethernet 0/0/1 //进入1接口
[SW3-Ethernet0/0/1] port link-type trunk //配置1接口为trunk
[SW3-Ethernet0/0/1] port trunk allow-pass vlan all //允许1接口通过的vlan为所有
[SW3]# interface Ethernet 0/0/2
[SW3-Ethernet0/0/2] port link-type trunk
[SW3-Ethernet0/0/2] port trunk allow-pass vlan all
[SW3]# interface Ethernet 0/0/20
[SW3-Ethernet0/0/20] port link-type access //配置20接口为access
[SW3-Ethernet0/0/20] port default vlan 10 //配置20接口只允许通过vlan10
(4)SW4配置
[SW4] vlan batch 2 20 //建立vlan 2、10
[SW4] interface Vlanif 2 //进入vlan 2
[SW4-Vlanif10] ip address 10.1.1.4 24 //配置vlan 2的网关,一般用于交换机管理地址
[SW4] interface Ethernet 0/0/1 //进入1接口
[SW4-Ethernet0/0/1] port link-type trunk //配置1接口为trunk
[SW4-Ethernet0/0/1] port trunk allow-pass vlan all //允许1接口通过的vlan为所有
[SW4]# interface Ethernet 0/0/2
[SW4-Ethernet0/0/2] port link-type trunk
[SW4-Ethernet0/0/2] port trunk allow-pass vlan all
[SW4]# interface Ethernet 0/0/20
[SW4-Ethernet0/0/20] port link-type access //配置20接口为access
[SW4-Ethernet0/0/20] port default vlan 20 //配置20接口只允许通过vlan20