©2008CiscoSystems,Inc.Allrightsreserved.Lesson6VLAN和生成树协议©2008CiscoSystems,Inc.Allrightsreserved.学习提纲•6.1VLAN操作介绍•6.2VTP(VLANTrunkProtocol)•6.3配置VLAN•6.4在VLAN中使用生成树协议©2008CiscoSystems,Inc.Allrightsreserved.©2004CiscoSystems,Inc.Allrightsreserved.ICNDv2.2—2-306VLAN和生成树协议6.1VLAN操作介绍©2008CiscoSystems,Inc.Allrightsreserved.VLAN=BroadcastDomain=LogicalNetwork(Subnet)6.1.1VLAN概述©2008CiscoSystems,Inc.Allrightsreserved.Segmentation©2008CiscoSystems,Inc.Allrightsreserved.Flexibility©2008CiscoSystems,Inc.Allrightsreserved.Security©2008CiscoSystems,Inc.Allrightsreserved.每个VLAN向物理网桥一样独立工作;通信只能在同一VLAN中进行(限制单播、组播和广播);VLAN能够跨越多个交换机时;中继链路(Trunk)能够携带多个VLAN的流量;Trunk使用特定的封装去区分不同的VLAN.交换机为每一个不同的VLAN维护一张不同的MAC地址表当交换机收到一个帧无法在MAC地址表中寻址的时候,交换机将把帧Flood(洪泛)到所有与源MAC地址所在同一VLAN端口和Trunk端口,除源端口。6.1.2VLAN操作©2008CiscoSystems,Inc.Allrightsreserved.6.1.3VLAN成员模式静态VLAN:基于端口手工配置动态VLAN:使用VLAN管理策略服务器(VMPS)©2008CiscoSystems,Inc.Allrightsreserved.6.1.4中继/主干链路(TrunkLink)访问链路(AccessLink):VLAN内部的链路,它只假定是广播域的一部分,帧在发到一个访问链路之前要删除所有的VLAN信息。中继链路(TrunkLink):可以是单个端口也可以是多个VLAN的一部分,可承载多个VLAN信息。Trunk端口带宽必须是100Mbps以上。©2008CiscoSystems,Inc.Allrightsreserved.IEEE802.1QTrunk©2008CiscoSystems,Inc.Allrightsreserved.802.1Q帧©2008CiscoSystems,Inc.Allrightsreserved.本征VLAN(NativeVLAN)©2008CiscoSystems,Inc.Allrightsreserved.•ISL是Cisco专用协议,用于封装和中继VLAN的流量•ISL接口必须至少支持100Mbit/s速率,推荐使用全双工模式•ISL由ASIC硬件完成,拥有更高的性能•ISL工作在OSI模型的第二层上,封装时增加新的数据头和CRCISLtrunk能够使VLAN穿越主干(backbone)ISLTrunk©2008CiscoSystems,Inc.Allrightsreserved.ISL封装©2008CiscoSystems,Inc.Allrightsreserved.©2004CiscoSystems,Inc.Allrightsreserved.ICNDv2.2—2-1606VLAN和生成树协议6.2VLANTrunkProtocol(VTP)©2008CiscoSystems,Inc.Allrightsreserved.•VTP是一个二层协议,用于在网络中维护VLAN的配置信息(添加、删除和更改);•使用VTP,可以保持VLAN配置的一致性;•一个以上共享VTP域名的相互连接的交换机构成一个VTP域;•仅在干道上传送VTP通告信息。6.2.1VTP特点©2008CiscoSystems,Inc.Allrightsreserved.6.2.2VTP的工作模式©2008CiscoSystems,Inc.Allrightsreserved.VTP通告以组播方式发送VTP服务器和客户机通过VTP修订号进行信息同步每5分钟或者当VLAN配置变化时发送VTP通告Note:VTP透明模式交换机的通告的修订号总是06.2.3VTP操作©2008CiscoSystems,Inc.Allrightsreserved.6.2.4VTP修剪(Pruning)©2008CiscoSystems,Inc.Allrightsreserved.©2004CiscoSystems,Inc.Allrightsreserved.ICNDv2.2—2-2106VLAN和生成树协议6.3配置VLAN©2008CiscoSystems,Inc.Allrightsreserved.6.3.1VLAN配置指南支持的VLAN数量取决于交换机型号大部分Catalyst桌面交换机支持64个VLANCDP和VTP通告在VLAN1上传输交换机的IP地址设置在管理VLAN上(默认为VLAN1)只有处于服务器和透明模式的交换机可以添加、删除VLAN2950交换机可以支持250个VLAN©2008CiscoSystems,Inc.Allrightsreserved.1增加一个VLANCatalyst2950SeriesSwitch#configureterminalSwitch(config)#vlan2Switch(config-vlan)#nameVLAN2wg_sw_a(config-vlan)#namevlan-namewg_sw_a#configureterminalwg_sw_a(config)#vlan2wg_sw_a(config-vlan)#nameswitchlab2©2008CiscoSystems,Inc.Allrightsreserved.2划分交换机的端口到VLANCatalyst2950Serieswg_sw_2950(config-if)#switchportaccess[vlanvlan#|dynamic]wg-sw_2950#configureterminalwg_sw_2950(config)#interfacefastethernet0/2wg_sw_2950(config-if)#switchportaccessvlan2wg_sw_2950#shvlanVLANNameStatusPorts-------------------------------------------------------------------1defaultactiveFa0/1,Fa0/3,Fa0/4.....2vlan2activeFa0/2©2008CiscoSystems,Inc.Allrightsreserved.3执行增加、移动、和改变VLANwg_sw_a(config)#vlanvlan-idwg_sw_a(config-vlan)#•EnterstheprivilegedEXECVLANconfigurationmode•WritesVLANadds,moves,andchangestothevlan.datfilewg_sw_a(config-if)#switchportaccessvlanvlan#•StaticallyassignsaVLANtoaspecificport©2008CiscoSystems,Inc.Allrightsreserved.4检查VLANCatalyst2950Serieswg_sw_2950#shvlanid2VLANNameStatusPorts----------------------------------------------------------------------------2switchlab99activeFa0/2,Fa0/12VLANTypeSAIDMTUParentRingNoBridgeNoStpBrdgModeTrans1Trans2--------------------------------------------------------------------2enet1000021500-----00...wg_sw_2950#wg_sw_2950#showvlan[brief|idvlan-id||namevlan-name]©2008CiscoSystems,Inc.Allrightsreserved.wg_sw_2950#showvlanbriefVLANNameStatusPorts----------------------------------------------------------------------------1defaultactiveFa0/1,Fa0/2,Fa0/3,Fa0/42vlan2active3vlan3active4vlan4active1002fddi-defaultact/unsup1003token-ring-defaultact/unsupVLANNameStatusPorts----------------------------------------------------------------------------1004fddinet-defaultact/unsup1005trnet-defaultact/unsupwg_sw_2950#showvlanbrief检查VLAN的成员关系wg_sw_2950#showinterfacesinterfaceswitchport©2008CiscoSystems,Inc.Allrightsreserved.6.3.2配置TrunkLink©2008CiscoSystems,Inc.Allrightsreserved.1配置802.1QTrunkwg_sw_a(config-if)#switchportmodetrunk•ConfigurestheportasaVLANtrunkNote:2950交换机只支持802.1Q封装类型wg_sw_a(config-if)#switchporttrunkencapsulationdot1q©2008CiscoSystems,Inc.Allrightsreserved.2配置ISLTrunkwg_sw_4000(config)#interface{fastethernet|gigabitethernet}slot/port选择一个将要被配置为Trunk的端口wg_sw_4000(config-if)#shutdown(可选项)关闭端口,阻止流量通过,直到配置完成wg_sw_4000(config-if)#switchporttrunkencapsulation{isl|dot1q|negotiate}(可选项)配置特定的封装。wg_sw_4000(config-if)#switchportmode{dynamic{auto|desirable}|trunk}配置接口作为第二层Trunk©2008CiscoSystems,Inc.Allrightsreserved.配置ISLTrunk实例wg_sw_4000#configureterminalwg_sw_4000(config-if)#interfacegigabitEthernet2/24wg_sw_4000(config-if)#shutdownwg_sw_4000(config-if)#switchpo