交換機是交換數據,只能識別MAC地址,而交換機可以轉發數據包,能夠識別IP地址,所以能夠轉發數據包。而三層交換機的也有路由功能,所以也能轉發數據包。今天這堂課就有三層交換機實現不同vlan間通信來加以驗證。
器材:三層交換機一臺,二層交換機一臺。電腦三臺,帶水晶頭雙絞線若干。
原理圖:
過程:
1:連線,把PC1,PC2分別連到三層交換機的fa0/1,fa0/6.把PC3連到二層交換機fa0/1。再用一根線一端連到二層交換機的fa0/10,另一端連到三層交換機fa0/10.
2:對交換機進行配置:
二層交換機的配置
Switch>en
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#int fa0/10
Switch(config-if)#sw mode acc
Switch(config-if)#sw mode trunk
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/10, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/10, changed state to up
Switch(config-if)#ex
Switch(config)#vlan 10
Switch(config-vlan)#ex
Switch(config)#int fa0/1
Switch(config-if)#sw acc vlan 10
Switch(config-if)#ex
Switch(config)#host 2chensw
三層交換機的配置
Switch>en
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#host 3chensw
3chensw(config)#vlan 10
3chensw(config-vlan)#exi
3chensw(config)#vlan 20
3chensw(config-vlan)#ex
3chensw(config)#int fa0/1
3chensw(config-if)#sw acc vlan 10
3chensw(config-if)#ex
3chensw(config)#int fa0/2
3chensw(config-if)#sw acc vlan 20
3chensw(config-if)#ex
3chensw(config)#int fa0/10
3chensw(config-if)#sw mode trunk
Command rejected: An interface whose trunk encapsulation is "Auto" can not be configured to "trunk" mode.
3chensw(config-if)#sw mode acc
3chensw(config-if)#sw mode trunk
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/10, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/10, changed state to up
3chensw(config-if)#int vlan 10
%LINK-5-CHANGED: Interface Vlan10, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan10, changed state to up
3chensw(config-if)#ip add 10.10.10.254 255.255.255.0
3chensw(config-if)#no shut
3chensw(config-if)#ex
3chensw(config)#int vlan 20
%LINK-5-CHANGED: Interface Vlan20, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan20, changed state to up
3chensw(config-if)#ip add 20.20.20.254 255.255.255.0
3chensw(config-if)#no shut
3:PC1,PC2,PC3的IP分別設爲:10.10.10.1,20.20.20.1,10.10.10.2.
4:測試:用PC1分別PING PC2,PC3.
PC>ping 10.10.10.2
Pinging 10.10.10.2 with 32 bytes of data:
Reply from 10.10.10.2: bytes=32 time=32ms TTL=128
Reply from 10.10.10.2: bytes=32 time=13ms TTL=128
Reply from 10.10.10.2: bytes=32 time=18ms TTL=128
Ping statistics for 10.10.10.2:
Packets: Sent = 3, Received = 3, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 13ms, Maximum = 32ms, Average = 21ms
PC>ping 20.20.20.1
Pinging 20.20.20.1 with 32 bytes of data:
Request timed out.
Reply from 20.20.20.1: bytes=32 time=5ms TTL=127
Reply from 20.20.20.1: bytes=32 time=3ms TTL=127
Reply from 20.20.20.1: bytes=32 time=3ms TTL=127
驗證完成,PC1,PC2間實現了 VLAN10和 VALN 20 之間的通信,以及通過設配串口fa0/10,實現在跨交換機之間通信。
總結:兩臺交換機及兩個vlan,配置的東西多了就有些容易混淆,導致浪費好多時間,驗證本身並不複雜,只是頭腦不清醒就容易差錯和配錯。所以要先把思路理好,理清了才動手是個好辦法。