2024年2月3日发(作者:)

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to upSwitch(config-if)#endSwitch#%SYS-5-CONFIG_I: Configured from console by consoleSwitch#show vlanVLAN Name Status Ports---- -------------------------------- --------- -------------------------------1 default active Fa0/4, Fa0/5, Fa0/6, Fa0/7Fa0/8, Fa0/9, Fa0/10, Fa0/11Fa0/12, Fa0/13, Fa0/14, Fa0/15Fa0/16, Fa0/17, Fa0/18, Fa0/19Fa0/20, Fa0/21, Fa0/22, Fa0/23Fa0/24, Gig1/1, Gig1/22 VLAN0002 active Fa0/23 VLAN0003 active Fa0/31002 fddi-default act/unsup1003 token-ring-default act/unsup1004 fddinet-default act/unsup1005 trnet-default act/unsupVLAN Type SAID MTU Parent RingNo BridgeNo Stp BrdgMode Trans1 Trans2---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------1 enet 100001 1500 - - - - - 0 02 enet 100002 1500 - - - - - 0 03 enet 100003 1500 - - - - - 0 01002 fddi 101002 1500 - - - - - 0 0--More--三层交换机Switch>enSwitch#conf tEnter configuration commands, one per line. End with CNTL/(config)#vlan 2Switch(config-vlan)#exitSwitch(config)#vlan 3Switch(config-vlan)#exitSwitch(config)#int fa 0/1Switch(config-if)#switchport trunk encapsulation dot1qSwitch(config-if)#switchport mode trunkSwitch(config-if)#switchport trunk allowed vlan 2,3Switch(config-if)#exitSwitch(config)#int fa 0/2Switch(config-if)#switchport access vlan 2Switch(config-if)#exitSwitch(config)#int vlan 2%LINK-5-CHANGED: Interface Vlan2, changed state to up%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan2, changed state to upSwitch(config-if)#ip address 192.168.1.1 255.255.255.0Switch(config-if)#no shutdownSwitch(config-if)#exitSwitch(config)#int vlan 3%LINK-5-CHANGED: Interface Vlan3, changed state to up%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan3, changed state to upSwitch(config-if)#ip address 192.168.2.1 255.255.255.0Switch(config-if)#no shutdownSwitch(config-if)#exitSwitch(config)#ip routingSwitch(config)#exitSwitch#%SYS-5-CONFIG_I: Configured from console by consoleSwitch#show ip routeCodes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGPD - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter areaN1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGPi - 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 - ODRP - periodic downloaded static routeGateway of last resort is not setC 192.168.1.0/24 is directly connected, Vlan2C 192.168.2.0/24 is directly connected, Vlan3Switch#show vlanVLAN Name Status Ports

---- -------------------------------- --------- -------------------------------1 default active Fa0/3, Fa0/4, Fa0/5, Fa0/6Fa0/7, Fa0/8, Fa0/9, Fa0/10Fa0/11, Fa0/12, Fa0/13, Fa0/14Fa0/15, Fa0/16, Fa0/17, Fa0/18Fa0/19, Fa0/20, Fa0/21, Fa0/22Fa0/23, Fa0/24, Gig0/1, Gig0/22 VLAN0002 active Fa0/23 VLAN0003 active1002 fddi-default act/unsup1003 token-ring-default act/unsup1004 fddinet-default act/unsup1005 trnet-default act/unsupVLAN Type SAID MTU Parent RingNo BridgeNo Stp BrdgMode Trans1 Trans2---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------1 enet 100001 1500 - - - - - 0 02 enet 100002 1500 - - - - - 0 03 enet 100003 1500 - - - - - 0 01002 fddi 101002 1500 - - - - - 0 0--More--<以上代码可复制粘贴,可往左滑>

测试PC1 分别 ping PC2 和 PC3PC>: 192.168.1.: 255.255.255.: 192.168.1.1PC>ping 192.168.2.2Pinging 192.168.2.2 with 32 bytes of data:Request timed from 192.168.2.2: bytes=32 time=25ms TTL=127Reply from 192.168.2.2: bytes=32 time=20ms TTL=127Reply from 192.168.2.2: bytes=32 time=20ms TTL=127Ping statistics for 192.168.2.2:Packets: Sent = 4, Received = 3, Lost = 1 (25% loss),Approximate round trip times in milli-seconds:Minimum = 20ms, Maximum = 25ms, Average = 21msPC>ping 192.168.2.2Pinging 192.168.2.2 with 32 bytes of data:Reply from 192.168.2.2: bytes=32 time=18ms TTL=127Reply from 192.168.2.2: bytes=32 time=23ms TTL=127Reply from 192.168.2.2: bytes=32 time=19ms TTL=127Reply from 192.168.2.2: bytes=32 time=22ms TTL=127Ping statistics for 192.168.2.2:Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),Approximate round trip times in milli-seconds:Minimum = 18ms, Maximum = 23ms, Average = 20msPC>ping 192.168.1.3Pinging 192.168.1.3 with 32 bytes of data:Reply from 192.168.1.3: bytes=32 time=15ms TTL=128Reply from 192.168.1.3: bytes=32 time=19ms TTL=128Reply from 192.168.1.3: bytes=32 time=15ms TTL=128Reply from 192.168.1.3: bytes=32 time=14ms TTL=128Ping statistics for 192.168.1.3:Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),Approximate round trip times in milli-seconds:Minimum = 14ms, Maximum = 19ms, Average = 15msPC2 分别 ping PC1 和 PC3PC>: 192.168.2.2

: 255.255.255.: 192.168.2.1PC>ping 192.168.1.2Pinging 192.168.1.2 with 32 bytes of data:Reply from 192.168.1.2: bytes=32 time=24ms TTL=127Reply from 192.168.1.2: bytes=32 time=23ms TTL=127Reply from 192.168.1.2: bytes=32 time=24ms TTL=127Reply from 192.168.1.2: bytes=32 time=20ms TTL=127Ping statistics for 192.168.1.2:Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),Approximate round trip times in milli-seconds:Minimum = 20ms, Maximum = 24ms, Average = 22msPC>ping 192.168.1.3Pinging 192.168.1.3 with 32 bytes of data:Reply from 192.168.1.3: bytes=32 time=13ms TTL=127Reply from 192.168.1.3: bytes=32 time=17ms TTL=127Reply from 192.168.1.3: bytes=32 time=19ms TTL=127Reply from 192.168.1.3: bytes=32 time=19ms TTL=127Ping statistics for 192.168.1.3:Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),Approximate round trip times in milli-seconds:Minimum = 13ms, Maximum = 19ms, Average = 17msPC3 分别 ping PC1 和 PC2PC>: 192.168.1.: 255.255.255.: 192.168.1.1PC>ping 192.168.1.2Pinging 192.168.1.2 with 32 bytes of data:Reply from 192.168.1.2: bytes=32 time=14ms TTL=128Reply from 192.168.1.2: bytes=32 time=17ms TTL=128Reply from 192.168.1.2: bytes=32 time=17ms TTL=128Reply from 192.168.1.2: bytes=32 time=16ms TTL=128Ping statistics for 192.168.1.2:Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),Approximate round trip times in milli-seconds:Minimum = 14ms, Maximum = 17ms, Average = 16msPC>ping 192.168.2.2Pinging 192.168.2.2 with 32 bytes of data:Request timed from 192.168.2.2: bytes=32 time=17ms TTL=127Reply from 192.168.2.2: bytes=32 time=16ms TTL=127Reply from 192.168.2.2: bytes=32 time=18ms TTL=127Ping statistics for 192.168.2.2:Packets: Sent = 4, Received = 3, Lost = 1 (25% loss),Approximate round trip times in milli-seconds:Minimum = 16ms, Maximum = 18ms, Average = 17msPC>ping 192.168.2.2Pinging 192.168.2.2 with 32 bytes of data:Reply from 192.168.2.2: bytes=32 time=15ms TTL=127Reply from 192.168.2.2: bytes=32 time=17ms TTL=127Reply from 192.168.2.2: bytes=32 time=14ms TTL=127Reply from 192.168.2.2: bytes=32 time=11ms TTL=127Ping statistics for 192.168.2.2:Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),Approximate round trip times in milli-seconds:Minimum = 11ms, Maximum = 17ms, Average = 14ms<以上代码可复制粘贴,可往左滑>