如果有多個vlan要做Routing的話,有個蠻好的解決方案是使用Layer 3 Switch做Routing,他的延展性很好,並且設定也很簡單
設定SW1的VLAN
Switch(config-if)#sw
Switch(config-if)#vlan 20
Switch(config-vlan)#vlan 30
Switch(config-vlan)#vlan 40
Switch(config-vlan)#int f0/2
Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan 20
Switch(config-if)#int f0/3
%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan20, changed state to up
Switch(config-if)#switchport access vlan 30
Switch(config-if)#switchport mode access
Switch(config-if)#int f0/4
Switch(config-if)#switchport access vlan 40
Switch(config-if)#switchport mode access
Switch(config-if)#int f0/10
Switch(config-if)#switchport mode trunk
設定Layer 3 Switch
1. Create VLAN and setup SVI
- Create VLAN
Layer3_Switch(config)#vlan 20
Layer3_Switch(config-vlan)#vlan 30
Layer3_Switch(config-vlan)#vlan 40
- Setup SVI: 這邊其實就是把SVI當成Router的default gateway那樣,所以也要設定ip
Layer3_Switch(config-if)#int vlan 20
Layer3_Switch(config-if)#ip address 192.168.0.1 255.255.255.0
Layer3_Switch(config-if)#int vlan 30
Layer3_Switch(config-if)#ip address 10.2.3.1 255.255.255.0
Layer3_Switch(config-if)#no shutdown
Layer3_Switch(config-if)#int vlan 40
Layer3_Switch(config-if)#ip address 172.16.20.1 255.255.255.0
Layer3_Switch(config-if)#no shutdown
Layer3_Switch(config-if)#int f0/10
Layer3_Switch(config-if)#switchport trunk encapsulation dot1q
Layer3_Switch(config-if)#switchport mode trunk
Layer3_Switch(config-if)#end
Layer3_Switch(config)#ip routing
- 檢查Routing設定
Layer3_Switch#show ip route
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
* - candidate default, U - per-user static route, o - ODR
P - periodic downloaded static routeGateway of last resort is not set10.0.0.0/24 is subnetted, 1 subnets
C 10.2.3.0 is directly connected, Vlan30
172.16.0.0/24 is subnetted, 1 subnets
C 172.16.20.0 is directly connected, Vlan40
C 192.168.0.0/24 is directly connected, Vlan20