1、 实验2 VLAN Trunking和VLAN配置 1.实验目的 通过本实验,你将可以掌握以下技能: ⑴ 进一步了解和掌握VALN的基本概念,掌握按端口划分VLAN的配置; ⑵ 通过VLAN Trunking配置跨交换机的VLAN; ⑶ 配置VTP; ⑷ 查看上述配置项目的有关信息。 2.实验拓扑 如图1所示,用交叉网线把C2950A交换机的FastEthernetO/12端口和C2950B交换机的FastEthernet0/12端口连接起来。 图1 交换机通过Trunk连接 3.实验要求 将交换机A的VTP配置成Ser
2、ver模式、交换机B为Client模式,两者同一VTP域名Test。在交换机A上配置VLAN。通过实验验证当在两者之间配置Trunk后,交换机B自动获得了与交换机A同样的VLAN配置。 4.实验步骤 电缆连接完成后,在超级终端正常开启的情况下,接通2950交换机的电源,实验开始。 第1步:配置C2950A交换机的VTP和VLAN 在2950系列交换机上配置VTP和VLAN的方法有两种,本实验演示的是使用vlan database命令的一种。 ⑴ 使用vlan database命令进入VLAN配置模式,在VLAN配置模式下,设置VTP的一系列属性,把C2950A交换机设置成VTP Se
3、rver模式(缺省配置),VTP域名为Test: C2950A#vlan database C2950A(vlan)#vtp server Setting device to VTP SERVER mode. C2950A(vlan)#vtp domain test Changing VTP domain name from exp to test . ⑵ 定义V10、V20、V30和V40等4个VLAN: C2950A(vlan)#vlan 10 name V10 VLAN 10 added: Name: V10 C2950A(vlan)#vlan 20 name
4、 V20 VLAN 20 added: Name: V20 C2950A(vlan)#vlan 30 name V30 VLAN 30 added: Name: V30 C2950A(vlan)#vlan 40 name V40 VLAN 40 added: Name: V40 每增加一个VLAN,交换机便显示增加VLAN信息。 ⑶ show vtp status命令显示VTP相关的配置和状态信息:主要应当关注VTP模式、域名、VLAN数量等信息。 C2950A#sh vtp status VTP Version
5、 : 2 Configuration Revision : 2 Maximum VLANs supported locally : 250 Number of existing VLANs : 9 VTP Operating Mode : Server VTP Domain Name : test VTP Pruning Mode : Disabled VTP V2 Mode : Disabled VTP Trap
6、s Generation : Disabled MD5 digest : 0x32 0x8C 0xD9 0x00 0xC1 0x05 0x3B 0x5F Configuration last modified by 192.168.1.1 at 3-1-93 00:03:47 ⑷ show vtp counters命令列出VTP的统计信息:各种VTP相关包的收发情况表明,因为C2950A交换机与C2950B交换机暂时还没有进行VTP信息的传输,所以各项数值均为0。 C2950A#sh vtp counters VTP
7、statistics: Summary advertisements received : 0 Subset advertisements received : 0 Request advertisements received : 0 Summary advertisements transmitted : 0 Subset advertisements transmitted : 0 Request advertisements transmitted : 0 Number of config revision errors : 0 Number
8、of config digest errors : 0 Number of V1 summary errors : 0 VTP pruning statistics: Trunk Join Transmitted Join Received Summary advts received from non-pruning-capable device ---------------- ---------------- ---------------- ----
9、 ⑸ 把端口分配给相应的VLAN,并将端口设置为静态VLAN访问模式: 在接口配置模式下用switchport access vlan和switchport mode access命令(只用后一条命令也可以)。 C2950A(config)#int fa0/1 C2950A(config-if)#switchport mode access C2950A(config-if)#switchport access vlan 10 C2950A(config-if)#int fa0/2 C2950A(config-if)#swit
10、chport mode access C2950A(config-if)#switchport access vlan 20 C2950A(config-if)#int fa0/3 C2950A(config-if)#switchport mode access C2950A(config-if)#switchport access vlan 30 C2950A(config-if)#int fa0/4 C2950A(config-if)#switchport mode access C2950A(config-if)#switchport access vlan 40
11、 第2步:配置C2950B交换机的VTP 配置C2950B交换机的VTP属性,域名设为Test,模式为Client。 C2950B#vlan database C2950B(vlan)#vtp domain test Changing VTP domain name from exp to test . C2950B(vlan)#vtp client Setting device to VTP CLIENT mode. 第3步:配置和监测两个交换机之间的VLAN Trunking ⑴ 将交换机A的24口配置成Trunk模式: C2950A(confi
12、g)#interface fa0/24 C2950A(config-if)#switchport mode trunk ⑵ 将交换机B的24口也配置成Trunk模式: C2950B(config)#interface fa0/24 C2950B(config-if)#switchport mode trunk ⑶ 用show interface fa0/24 switchport查看Fa0/24端口上的交换端口属性,我们关心的是几个与Trunk相关的信息。它们是:运行方式为Trunk、封装格式为802.1Q、Trunk中允许所有VLAN传输等。 C2950B#sh
13、int fa0/24 switchport Name: Fa0/24 Switchport: Enabled Administrative Mode: trunk Operational Mode: trunk Administrative Trunking Encapsulation: dot1q Operational Trunking Encapsulation: dot1q Negotiation of Trunking: On Access Mode VLAN: 1 (default) Trunking Native Mode VLAN: 1 (default)
14、Trunking VLANs Enabled: ALL Pruning VLANs Enabled: 2-1001 Protected: false Voice VLAN: none (Inactive) Appliance trust: none 第4步:查看C2950B交换机的VTP和VLAN信息 完成两台交换机之间的Trunk配置后,在C2950B上发出命令查看VTP和VLAN信息: C2950B#sh vtp status VTP Version : 2 Configuration Revision
15、 : 2 Maximum VLANs supported locally : 250 Number of existing VLANs : 9 VTP Operating Mode : Client VTP Domain Name : Test VTP Pruning Mode : Disabled VTP V2 Mode : Disabled VTP Traps Generation : Disabled
16、 MD5 digest : 0x74 0x33 0x77 0x65 0xB1 0x89 0xD3 0xE9 Configuration last modified by 0.0.0.0 at 3-1-93 00:20:23 Local updater ID is 0.0.0.0 (no valid interface found) C2950B#sh vlan brief VLAN Name Status Ports ---- -------------------------
17、 --------- ------------------------------- 1 default active Fa0/1, Fa0/2, Fa0/3, Fa0/4 Fa0/5, Fa0/6, Fa0/7, Fa0/8 Fa0/9, Fa0/10, Fa0/11, Fa0/12
18、 Fa0/13, Fa0/14, Fa0/15, Fa0/16 Fa0/17, Fa0/18, Fa0/19, Fa0/20 Fa0/21, Fa0/22, Fa0/23, Fa0/24 Gi0/1, Gi0/2 10 V10
19、 active 20 V20 active 30 V30 active 40 V40 active 1002 fddi-default active 1003 token-ring-default active 1004 fddinet-default
20、 active 1005 trnet-default active 可以看到C2950B交换机已经自动获得C2950A交换机上的VLAN配置。 【注意】:虽然交换机可以通过VTP学到VLAN配置信息,但交换机端口的划分是学不到的,而且每台交换机上端口的划分方式各不一样,需要分别配置! 【问题1】:在配置VLAN Trunking前,交换机B能否从交换机A学到VLAN配置? 若为交换机A的vlan1配置好地址,在交换机B上对交换机A的vlan1接口用ping命令验证两台交换机的连通情况,输出结果也将表明C2950A和C2950B之间在IP层是连通的,同时再次验证了Trunking的工作是正常的。 5.实验问题参考答案 【问题1】:不可以。VLAN信息的传播必须通过Trunk链路,所以只有配置好Trunk链路后,VLAN信息才能从交换机A传播到交换机B。






