当前位置:文档之家› 生成树的详细配置及实验

生成树的详细配置及实验

STP及其优化实验拓扑图:实验步骤:1. 设置SW1,SW2,SW3主机名分别为Core1,Core2, ED-SW2. 把Core1与Core2间的两条链路绑定成etherchannel2,并设置成Trunk mode Core1:interface range fa0/23 - 24switchport trunk encapsulation dot1q //支持ISL及dot1Q的交换机必须设置trunk的封装协议。

低端的C2950,C2960,C2918只支持dot1Q,无此命令。

switch mode trunk //接口设置为Trunk模式。

channel-group 2 mode on //接口加入Etherchannel2。

Creating a port-channel interface Port-channel 2//系统提示自动创建port-channel2。

interface Port-channel2 // Port-channel2接口配置必须同物理接口一致。

switchport trunk encapsulation dot1qswitchport mode trunkCore2:interface range fa0/23 - 24switchport trunk encapsulation dot1qswitch mode trunkchannel-group 2 mode onCreating a port-channel interface Port-channel 2interface Port-channel2switchport trunk encapsulation dot1qswitchport mode trunk3.验证etherchannel设置Core1#sh etherchannel summary //显示etherchannel的详细信息Flags: D - down P - in port-channelI - stand-alone s - suspendedH - Hot-standby (LACP only)R - Layer3 S - Layer2U - in use f - failed to allocate aggregatoru - unsuitable for bundlingw - waiting to be aggregatedd - default portNumber of channel-groups in use: 1 //目前已经建好1个etherchannel。

Number of aggregators: 1Group Port-channel Protocol Ports------+-------------+-----------+-----------------------------------------------2 Po2(SU) - fa0/23(P) fa0/24(P) // S - Layer2 U - in use P - in port-channel4. Core1,Core2,ED-SW间的所有链路均设置成TrunkED-SW:int range f0/23 – 24no shutdownswitchport mode trunkCore1:int f0/21switch trunk encap dot1qswitch mode trunkCore2:int f0/21switch trunk encap dot1qswitch mode trunk5.验证etherchannel设置Core2#show interface trunkPort Mode Encapsulation Status Native vlanFa0/21 on 802.1q trunking 1 // F0/21,Trunk模式为ON,封装为802.1q,目前已经形成Trunking,native vlan为vlan 1。

Po2 on 802.1q trunking 1Port Vlans allowed on trunkFa0/21 1-4094 //此Trunk允许所有的vlan流量通过。

Po2 1-4094Port Vlans allowed and active in management domainFa0/21 1 //此交换域只有vlan 1是活动的vlan。

因为现在无其他vlan Po2 1Port Vlans in spanning tree forwarding state and not prunedFa0/21 1 //Vlan没有被vtp修剪Po2 16.添加vlan1-10,奇数vlan生成树根选择Core1,偶数vlan生成树根选择Core2 Core1,Core2,ED-SW:vlan 2 //添加vlan 2name testvlan2 //命名vlan 2为testvlan2vlan 3name testvlan3vlan 4name testvlan4vlan 5name testvlan5vlan 6name testvlan6vlan 7name testvlan7vlan 8name testvlan8vlan 9name testvlan9vlan 10name testvlan107.验证新添加的vlanCore1#sh vlan brief // Vlan标号列,vlan名字,状态,及对应端口VLAN Name Status Ports--------------------------------------------- -------------------------------1 default active Fa0/1, Fa0/2, Fa0/3, Fa0/4Fa0/5, Fa0/6, Fa0/7, Fa0/8Fa0/9, Fa0/10, Fa0/11, Fa0/12Fa0/13, Fa0/14, Fa0/15, Fa0/16Fa0/17, Fa0/18, Fa0/19, Fa0/20Fa0/22, Gi0/1, Gi0/2//这些端口默认划分到vlan1,注意Fa0/21,23,24不在这里,因为这3个端口做成了Trunk2 testvlan2 active――――部分输出忽略――――――9 testvlan9 active10 testvlan10 active1002 fddi-default act/unsup //这些为特殊vlan,现在基本不用1003 token-ring-default act/unsup8.验证新添加的vlanCore1#sh spanning-treeVLAN0001Spanning tree enabled protocol ieee //Spanning-tree为ieee标准Root ID Priority 32769 //此交换机vlan 1的优先级=默认32728+vlan 的标号,则vlan2为32768+2,其他vlan类似。

Address 000d.65dc.8800 //交换机MACThis bridge is the root //此交换机已经成为valn1的root,默认情况一台交换机成为所有vlan的rootHello Time 2 sec Max Age 20 sec Forward Delay 15 secBridge ID Priority 32769 (priority 32768 sys-id-ext 1)Address 000d.65dc.8800Hello Time 2 sec Max Age 20 sec Forward Delay 15 secAging Time 300Interface Role Sts Cost Prio.Nbr Type---------------- ---- --- --------- -------- --------------------------------Fa0/4 Desg FWD 19 128.4 P2pFa0/21 Desg FWD 19 128.21 P2p //F0/21为指定端口,处于转发状态,STP Cost为19Po2 Desg FWD 12 128.65 P2pVLAN0002Spanning tree enabled protocol ieeeRoot ID Priority 32770Address 000d.65dc.8800This bridge is the rootHello Time 2 sec Max Age 20 sec Forward Delay 15 secBridge ID Priority 32770 (priority 32768 sys-id-ext 2)Address 000d.65dc.8800Hello Time 2 sec Max Age 20 sec Forward Delay 15 secAging Time 300Interface Role Sts Cost Prio.Nbr Type---------------- ---- --- --------- -------- --------------------------------Fa0/21 Desg FWD 19 128.21 P2pPo2 Desg FWD 12 128.65 P2p9. 设置Core1为vlan 1,3,5,7,9的主根作为vlan2,4,6,8,10的次根设置Core2为vlan2,4,6,8,10的主根作为vlan1,3,5,7,9的次根Core1:spanning-tree vlan 1,3,5,7,9 root primaryspanning-tree vlan 2,4,6,8,10 root secondaryCore2:spanning-tree vlan 1,3,5,7,9 root secondaryspanning-tree vlan 2,4,6,8,10 root primary10.验证根配置Core1#sh spanning-treeVLAN0001Spanning tree enabled protocol ieeeRoot ID Priority 24577Address 000d.65dc.8800This bridge is the rootHello Time 2 sec Max Age 20 sec Forward Delay 15 secBridge ID Priority 24577 (priority 24576 sys-id-ext 1)Address 000d.65dc.8800Hello Time 2 sec Max Age 20 sec Forward Delay 15 secAging Time 300Interface Role Sts Cost Prio.Nbr Type---------------- ---- --- --------- -------- --------------------------------Fa0/4 Desg FWD 19 128.4 P2pFa0/21 Desg FWD 19 128.21 P2pPo2 Desg FWD 12 128.65 P2pVLAN0002Spanning tree enabled protocol ieeeRoot ID Priority 24578 //根网桥优先级及MAC,vlan2的根已经变成了Core2 Address 0013.80e2.4880Cost 12Port 65 (Port-channel2)Hello Time 2 sec Max Age 20 sec Forward Delay 15 secBridge ID Priority 28674 (priority 28672 sys-id-ext 2) 本网桥优先级及MAC地址Address 000d.65dc.8800Hello Time 2 sec Max Age 20 sec Forward Delay 15 secAging Time 300Interface Role Sts Cost Prio.Nbr Type---------------- ---- --- --------- -------- --------------------------------Fa0/21 Desg FWD 19 128.21 P2pPo2 Root FWD 12 128.65 P2p //指定端口变成了根端口Core1#sh runspanning-tree mode pvst //生成树模式,默认为PVSTspanning-tree vlan 1,3,5,9 priority 24576spanning-tree vlan 2,4,6,8,10 priority 28672 //命令被自动转换,也可以直接使用此命令11.把PC接入到ED-SW的Fa0/2,并记录端口指示灯转换到绿色的时间___S为了解决交换机端口转发延迟问题,启用Fa0/2的portfast功能ED-SW:ed-sw(config-if)#spanning-tree portfast%Warning: portfast should only be enabled on ports connected to a singlehost. Connecting hubs, concentrators, switches, bridges, etc... to thisinterface when portfast is enabled, can cause temporary bridging loops.Use with CAUTION//告警信息,建议启用了portfast功能的接口只连接单台主机,接其他设备可能会发生环路%Portfast has been configured on FastEthernet0/2 but will onlyhave effect when the interface is in a non-trunking mode.// Portfast功能只在非Trunk模式下生效注:也可以在全局模式下输入spanning-tree portfast default启用所有的端口portfast功能12.重新插拔PC与ED-SW的网线,再次记录端口指示灯转换到绿色的时间__S验证portfast已经在Fa0/2口上启用ed-sw#sh spanning-tree interface f0/2 portfastVLAN0001 enabled13.配置PC IP地址:192.168.88.203/24配置Core1 Vlan1 IP地址:192.168.88.201/24配置Core2 Vlan1 IP地址:192.168.88.202/24Core1:interface Vlan1ip address 192.168.88.201 255.255.255.0no shutendCore2:interface Vlan1ip address 192.168.88.202 255.255.255.0end14.在PC的DOS命令行下:ping 192.168.88.201 -t //不停的Ping 192.168.88.201断掉ED-SW到Core1的连接,记录ping包丢失了___个15.在ED-SW上配置uplinkfasted-sw(config)#spanning-tree uplinkfast16.验证uplinkfasted-sw#sh spanning-tree uplinkfastUplinkFast is enabled17.在PC的DOS命令行下:ping 192.168.88.201 -t //不停的Ping 192.168.88.201断掉ED-SW到Core1的连接,记录ping包丢失了__个20.验证RSTP是否启用ed-sw#sh spanning-treeVLAN0001Spanning tree enabled protocol rstp //生成树模式Root ID Priority 24577Address 000d.65dc.8800Cost 19Port 23 (FastEthernet0/23)Hello Time 2 sec Max Age 20 sec Forward Delay 15 secBridge ID Priority 32769 (priority 32768 sys-id-ext 1)Address 000d.bdbb.7480Hello Time 2 sec Max Age 20 sec Forward Delay 15 secAging Time 300Interface Role Sts Cost Prio.Nbr Type---------------- ---- --- --------- -------- -------------------------------- Fa0/2 Desg FWD 19 128.2 Edge P2p //边缘端口Fa0/4 Desg BLK 19 128.4 P2pFa0/23 Root FWD 19 128.23 P2pFa0/24 Altn BLK 19 128.24 P2p //被阻塞的端口VLAN0002Spanning tree enabled protocol rstpRoot ID Priority 24578Address 0013.80e2.4880Cost 19Port 24 (FastEthernet0/24)Hello Time 2 sec Max Age 20 sec Forward Delay 15 secBridge ID Priority 32770 (priority 32768 sys-id-ext 2)Address 000d.bdbb.7480Hello Time 2 sec Max Age 20 sec Forward Delay 15 secAging Time 300Interface Role Sts Cost Prio.Nbr Type---------------- ---- --- --------- -------- -------------------------------- Fa0/23 Altn BLK 19 128.23 P2pFa0/24 Root FWD 19 128.24 P2p在PC的DOS命令行下:ping 192.168.88.201 -t //不停的Ping 192.168.88.201断掉ED-SW到Core1的连接,记录ping包丢失了__个21.配置MSTCore1,Core2,ED-SW上启用两个MST Instance 1,2Vlan1,3,5,7,9映射到Instance 1Vlan2,4,6,8,10映射到Instance 2Core1 instance 1优先级设为 4096Instacen 2优先级设置 16384Core2 instance 1优先级设为 16384Instacen 2优先级设置 4096Core1:spanning-tree mode mstspanning-tree mst configurationinstance 1 vlan 1, 3, 5, 7, 9instance 2 vlan 2, 4, 6, 8, 10spanning-tree mst 1 priority 16384spanning-tree mst 2 priority 8192Core2:spanning-tree mode mstspanning-tree mst configurationinstance 1 vlan 1, 3, 5, 7, 9instance 2 vlan 2, 4, 6, 8, 10spanning-tree mst 1 priority 16384spanning-tree mst 2 priority 8192ED-SW:spanning-tree mode mstspanning-tree mst configurationinstance 1 vlan 1, 3, 5, 7, 9instance 2 vlan 2, 4, 6, 8, 1022.验证MST配置Core2#sh spanning-treeMST0Spanning tree enabled protocol mstpRoot ID Priority 32768Address 000d.65dc.8800Cost 0Port 65 (Port-channel2)Hello Time 2 sec Max Age 20 sec Forward Delay 15 secBridge ID Priority 32768 (priority 32768 sys-id-ext 0)Address 0013.80e2.4880Hello Time 2 sec Max Age 20 sec Forward Delay 15 secInterface Role Sts Cost Prio.Nbr Type---------------- ---- --- --------- -------- -------------------------------- Fa0/4 Desg FWD 200000 128.4 P2pFa0/21 Desg FWD 200000 128.21 P2p Pre-STD-RxPo2 Root FWD 100000 128.65 P2pMST1Spanning tree enabled protocol mstpRoot ID Priority 16385Address 0013.80e2.4880This bridge is the rootHello Time 2 sec Max Age 20 sec Forward Delay 15 secBridge ID Priority 16385 (priority 16384 sys-id-ext 1)Address 0013.80e2.4880Hello Time 2 sec Max Age 20 sec Forward Delay 15 secInterface Role Sts Cost Prio.Nbr Type---------------- ---- --- --------- -------- -------------------------------- Fa0/4 Desg FWD 200000 128.4 P2pFa0/21 Desg FWD 200000 128.21 P2p Pre-STD-RxPo2 Desg FWD 100000 128.65 P2pMST2Spanning tree enabled protocol mstpRoot ID Priority 8194Address 0013.80e2.4880This bridge is the rootHello Time 2 sec Max Age 20 sec Forward Delay 15 secBridge ID Priority 8194 (priority 8192 sys-id-ext 2)Address 0013.80e2.4880Hello Time 2 sec Max Age 20 sec Forward Delay 15 secInterface Role Sts Cost Prio.Nbr Type---------------- ---- --- --------- -------- --------------------------------Fa0/21 Desg FWD 200000 128.21 P2p Pre-STD-RxPo2 Desg FWD 100000 128.65 P2p23.配置ED-SW BPDU Guarded-sw(config-if)#int f0/24ed-sw(config-if)#spanning-tree bpduguard enableed-sw(config-if)#02:51:16: %SPANTREE-2-BLOCK_BPDUGUARD: Received BPDU on port FastEthernet0/24 with BPDU Guard enabled. Disabling port. //端口启用此功能后,收到任何BPDU信息,则此端口进入err-disable状态02:51:16: %PM-4-ERR_DISABLE: bpduguard error detected on Fa0/24, putting Fa0/24 in err-disable state02:51:17: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/24, changed state to down 24.配置ED-SW F0/24端口,启用Guard Root功能ed-sw(config-if)#spanning-tree guard root02:54:56: %SPANTREE-2-ROOTGUARD_CONFIG_CHANGE: Root guard enabled on port FastEthernet0/24. 02:54:56: %SPANTREE-2-ROOTGUARD_BLOCK: Root guard blocking port FastEthernet0/24 on MST00. //启用此功能后,如果F0/24端口接入了>=目前根交换机生成树优先级的交换机,则Block此端口25. 验证ED-SW的STP状态ed-sw#sh spanning-treeMST00Spanning tree enabled protocol mstpRoot ID Priority 32768Address 000d.65dc.8800Cost 0Port 23 (FastEthernet0/23)Hello Time 2 sec Max Age 20 sec Forward Delay 15 secBridge ID Priority 32768 (priority 32768 sys-id-ext 0)Address 000d.bdbb.7480Hello Time 2 sec Max Age 20 sec Forward Delay 15 secInterface Role Sts Cost Prio.Nbr Type---------------- ---- --- --------- -------- --------------------------------Fa0/2 Desg FWD 200000 128.2 Edge P2pFa0/4 Desg FWD 200000 128.4 P2pFa0/23 Root FWD 200000 128.23 P2pFa0/24 Desg BKN*200000 128.24 P2p *ROOT_Inc // F0/24收到了相同优先级BPDU,则阻塞此端口,并提示根不一致信息MST01Spanning tree enabled protocol mstpRoot ID Priority 16385Address 0013.80e2.4880Cost 300000Port 23 (FastEthernet0/23)Hello Time 2 sec Max Age 20 sec Forward Delay 15 secBridge ID Priority 32769 (priority 32768 sys-id-ext 1)Address 000d.bdbb.7480Hello Time 2 sec Max Age 20 sec Forward Delay 15 secInterface Role Sts Cost Prio.Nbr Type---------------- ---- --- --------- -------- --------------------------------Fa0/2 Desg FWD 200000 128.2 Edge P2pFa0/4 Desg LRN 200000 128.4 P2pFa0/23 Root FWD 200000 128.23 P2pFa0/24 Desg BKN*200000 128.24 P2p *ROOT_Inc26.配置Core1与Core2互联的接口启用udld功能Core1,Core2:interface range F0/23 - 24udld port27.验证udld配置Core1#sh udld f0/23Interface Fa0/23---Port enable administrative configuration setting: Enabled //配置启用Port enable operational state: Enabled //已经正常运行Current bidirectional state: Bidirectional //双向学到对等体,Current operational state: Advertisement - Single neighbor detected //检测到一个邻居Message interval: 7Time out interval: 5Entry 1---Expiration time: 41Cache Device index: 1Current neighbor state: BidirectionalDevice ID: CAT0912R1HWPort ID: Fa0/23Neighbor echo 1 device: CAT0730X1HNNeighbor echo 1 port: Fa0/23Message interval: 15Time out interval: 5CDP Device name: Core228.实验完成。

相关主题