首页 > 代码库 > 三层交换机的路由功能实现VALN间通信
三层交换机的路由功能实现VALN间通信
交换机是交换数据,只能识别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,配置的东西多了就有些容易混淆,导致浪费好多时间,验证本身并不复杂,只是头脑不清醒就容易差错和配错。所以要先把思路理好,理清了才动手是个好办法。
三层交换机的路由功能实现VALN间通信