【思科实验】Trunk 配置完整实验|看懂跨交换机 VLAN 通信原理

🎯 实验目的
1、理解 Trunk 的运行原理,搞懂 802.1Q 标签封装
2、掌握 Trunk 接口配置、验证排错方法

📋 实验需求
1、根据实验拓扑图,完成设备的基本配置;
2、分别在SW1和SW2创建VLAN10和VLAN20,名字为IT和HR;
3、分别在SW1和SW2上把相应的接口划入VLAN10和VLAN20;
4、把SW1和SW2互连的链路配置成Trunk,采用Dot1q封装;
5、测试PC之间的网络连通性。

教学视频来了
https://mp.weixin.qq.com/s/g9pzfgN3_wAURg-ouYa56g
📝 完整实验步骤

步骤1:设备的基本配置
配置PC1:
VPCS>set pcname PC1 //设置主机名PC1> ip 10.1.1.1/24 //设置IP地址
配置PC2:
VPCS>set pcname PC2PC2> ip 10.1.2.1/24
配置PC3:
VPCS>set pcname PC3PC3> ip 10.1.1.2/24
配置PC4:
VPCS>set pcname PC4PC4> ip 10.1.2.2/24
配置SW1:
Switch>enableSwitch#configure terminalSwitch(config)#hostname SW1SW1(config)#no ip domain-lookupSW1(config)#line console 0SW1(config-line)#exec-timeout 0 0SW1(config-line)#logging synchronousSW1(config-line)#endSW1#
配置SW2:
Switch>enableSwitch#configure terminalSwitch(config)#hostname SW2SW2(config)#no ip domain-lookupSW2(config)#line console 0SW2(config-line)#exec-timeout 0 0SW2(config-line)#logging synchronousSW2(config-line)#endSW2#
步骤2:VLAN的配置
配置SW1:
SW1(config)#vlan 10SW1(config-vlan)#name ITSW1(config-vlan)#exitSW1(config)#vlan 20SW1(config-vlan)#name HRSW1(config-vlan)#exitSW1(config)#interface Eth0/1SW1(config-if)#switchport mode accessSW1(config-if)#switchport access vlan 10SW1(config-if)#exitSW1(config)#interface Eth0/2SW1(config-if)#switchport mode accessSW1(config-if)#switchport access vlan 20SW1(config-if)#endSW1#
配置SW2:
SW2(config)#vlan 10SW2(config-vlan)#name ITSW2(config-vlan)#exitSW2(config)#vlan 20SW2(config-vlan)#name HRSW2(config-vlan)#exitSW2(config)#interface Eth0/1SW2(config-if)#switchport mode accessSW2(config-if)#switchport access vlan 10SW2(config-if)#exitSW2(config)#interface Eth0/2SW2(config-if)#switchport mode accessSW2(config-if)#switchport access vlan 20SW2(config-if)#endSW2#
步骤3:Trunk的配置
配置SW1:
SW1(config)#interface Eth0/0SW1(config-if)#switchport trunk encapsulation dot1qSW1(config-if)#switchport mode trunkSW1(config-if)#endSW1#
配置SW2:
SW2(config)#interface Eth0/0SW2(config-if)#switchport trunk encapsulation dot1qSW2(config-if)#switchport mode trunkSW2(config-if)#endSW2#
实验检查
步骤1:检查VLAN
检查SW1:
SW1#showvlan briefVLANName Status Ports------------------------------------ --------- -------------------------------1default active Et0/310IT active Et0/120HR active Et0/21002fddi-default act/unsup1003token-ring-default act/unsup1004fddinet-default act/unsup1005trnet-default act/unsupSW1已经创建好VLAN10和VLAN20,并已将对应接口划入。
检查SW2:
SW2#showvlan briefVLANName Status Ports------------------------------------ --------- -------------------------------1default active Et0/310IT active Et0/120HR active Et0/21002fddi-default act/unsup1003token-ring-default act/unsup1004fddinet-default act/unsup1005trnet-default act/unsupSW2已经创建好VLAN10和VLAN20,并已将对应接口划入。
步骤2:检查Trunk
检查SW1:
SW1#showinterfaces Eth0/0 switchportName: Et0/0Switchport: EnabledAdministrativeMode: trunkOperationalMode: trunkAdministrativeTrunking Encapsulation: dot1qOperationalTrunking Encapsulation: dot1qNegotiationof Trunking: OnAccessMode VLAN: 1 (default)TrunkingNative Mode VLAN: 1 (default)AdministrativeNative VLAN tagging: enabledVoiceVLAN: noneAdministrativeprivate-vlan host-association: noneAdministrativeprivate-vlan mapping: noneAdministrativeprivate-vlan trunk native VLAN: noneAdministrativeprivate-vlan trunk Native VLAN tagging: enabledAdministrativeprivate-vlan trunk encapsulation: dot1qAdministrativeprivate-vlan trunk normal VLANs: noneAdministrativeprivate-vlan trunk associations: noneAdministrativeprivate-vlan trunk mappings: noneOperationalprivate-vlan: noneTrunkingVLANs Enabled: ALLPruningVLANs Enabled: 2-1001CaptureMode DisabledCaptureVLANs Allowed: ALLProtected: falseAppliancetrust: noneE0/0接口当前是Trunk,封装的协议是dot1q。SW1#showinterfaces trunkPortMode Encapsulation Status Native vlanEt0/0on 802.1q trunking 1PortVlans allowed on trunkEt0/01-4094PortVlans allowed and active in management domainEt0/01,10,20PortVlans in spanning tree forwarding state and not prunedEt0/01,10,20E0/0封装的Trunk协议是dot1q,当前的状态是trunking。SW1#shrun int Eth0/0Buildingconfiguration...Currentconfiguration : 90 bytes!interfaceEthernet0/0switchporttrunk encapsulation dot1qswitchportmode trunkendE0/0接口的Trunk封装协议是dot1q,模式是trunk。
检查SW2:
SW2#show interfaces trunkPort Mode Encapsulation Status Native vlanEt0/0 on 802.1q trunking 1Port Vlans allowed on trunkEt0/01-4094Port Vlans allowed and active in management domainEt0/01,10,20Port Vlans in spanning tree forwarding state andnot prunedEt0/01,10,20E0/0封装的Trunk协议是dot1q,当前的状态是trunking。
步骤4:网络连通性测试
测试PC1和PC3的连通性:
PC1> ping 10.1.1.284 bytes from10.1.1.2 icmp_seq=1 ttl=64 time=1.603 ms84 bytes from10.1.1.2 icmp_seq=2 ttl=64 time=1.234 ms84 bytes from10.1.1.2 icmp_seq=3 ttl=64 time=1.027 ms84 bytes from10.1.1.2 icmp_seq=4 ttl=64 time=2.372 ms84 bytes from10.1.1.2 icmp_seq=5 ttl=64 time=1.200 msPC1和PC3的网络连通性正常。
测试PC2和PC4的连通性:
PC2> ping 10.1.2.284 bytes from10.1.2.2 icmp_seq=1 ttl=64 time=0.887 ms84 bytes from10.1.2.2 icmp_seq=2 ttl=64 time=0.932 ms84 bytes from10.1.2.2 icmp_seq=3 ttl=64 time=1.295 ms84 bytes from10.1.2.2 icmp_seq=4 ttl=64 time=0.926 ms84 bytes from10.1.2.2 icmp_seq=5 ttl=64 time=1.011 msPC2和PC4的网络连通性正常。
💡 知识点小结
-
Access 口:属于一个 VLAN,收发无标签帧,接终端 PC
-
Trunk 口:承载多个 VLAN,用 802.1Q 给帧打标签,交换机之间互联使用
-
802.1Q 标签:在以太网帧头部插入 4 字节 VLAN 标签,区分流量所属 VLAN
🔥 这个 Trunk 实验,正是思科 CCNA 核心考点! 从 VLAN、Access、Trunk,到后续 STP、三层 VLANIF、路由交换,整套企业网络体系都在思科认证体系里。
DAMO开发者矩阵,由阿里巴巴达摩院和中国互联网协会联合发起,致力于探讨最前沿的技术趋势与应用成果,搭建高质量的交流与分享平台,推动技术创新与产业应用链接,围绕“人工智能与新型计算”构建开放共享的开发者生态。
更多推荐


所有评论(0)