RSTP-MSTP

别来无恙 提交于 2020-03-11 06:41:05

一、STP

1.STP的端口状态

a.侦听(listening)15s

b.学习(learning)15s

c.转发(forwarding)

d.阻塞(blocking)20s

2.STP选举

a.选举根桥:先比较优先级,再比较MAC地址,越小越好,默认32768

b.选举根端口,每个非根交换机只有一个根端口,通过比较cost值,按入口方向计算

c.选举指定端口,根桥的所有端口都是指定端口

总结:

a.每个冲突域只有一个指定端口

b.根桥的所有端口都是指定端口

c.比较到根桥的开销

d.如果cost值相同,则比较自己的优先级和MAC

二、.portfast(又叫边缘端口)

a.相对普通STP,节省30s

b.不要在接交换机的接口开启

c.不能在开启portfast的接口上开启trunk

d.一般用在接入层交换机

命令:

R1(config)#spanning-tree portfast

如果要在交换机上全部开启:

SW1(config)#spanning-tree portfast default

如果要在某个接口上禁用此功能:

SW1(config)#spanning-tree portfast disable

三、uplinkfast 

1.block端口要过30s才能转为forwarding状态,为了能快速转为fordwarding状态,我们可以用uplinkfast技术

SW1(config)#spanning-tree uplinkfast

2.全局起效,一般用于接入层交换机  

3.启用后与未启用相比有三点变化:增加了uplinkfast标识,将优先级强制改为49152,cost值增加3000

四、backbone fast  

sw1和sw3之间的骨干线路down了,看sw2 9口何时可以恢复

1.建议所有交换机都启用

2.节约是BLK到LIS的20s老化时间

3.sw2启用backbone fast后,收到次级BPDU后,会通过RP发送一个RLQ(router link quest)命令,根桥收到后,回应response,sw2收到后,会将9口直接从BLK转为LIS状态;

五、RSTP(Rapid Spanning Tree Protocol,802.1w)

1.RSTP端口状态:

a.discarding(BLK&LIS):

b.learning:

c.forwarding:

2.RSTP端口角色:

 

3.RSTP的过程

根桥发送proposal,A收到后,将其他所有接口全部同步(BLK),回应agreement

4.建议在所有交换机上都配置

 五、MSTP(Multiple STP,802.1S)

1.针对一个网络中有大量VLAN(上千个),这时如果还用PVST,每两秒根桥就要发送上千个BPDU,会造成收敛很慢,消耗大量资源,这时就可应用MSTP,MSTP就是将VLAN分组,每一组有不同的根桥和备份根桥

2.

3.配置:

a.开启mst:

SW1(config)#spanning-tree mode mst

 

SW1(config)#do sh spanning-tree 

MST0
  Spanning tree enabled protocol mstp
  Root ID    Priority    32768
             Address     aabb.cc00.0100
             This bridge is the root
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec

  Bridge ID  Priority    32768  (priority 32768 sys-id-ext 0)
             Address     aabb.cc00.0100
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec

Interface           Role Sts Cost      Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
Et0/0               Desg BLK 2000000   128.1    Shr 
Et0/1               Desg BLK 2000000   128.2    Shr 
Et0/2               Desg BLK 2000000   128.3    Shr 
Et0/3               Desg BLK 2000000   128.4    Shr 
Et1/0               Desg BLK 2000000   128.5    Shr 
Et1/1               Desg BLK 2000000   128.6    Shr 
Et1/2               Desg BLK 2000000   128.7    Shr 
Et1/3               Desg BLK 2000000   128.8    Shr 

b.配置mst

SW1(config)#spanning-tree mst configuration 
SW1(config-mst)#instance 1 vlan 1-5
SW1(config-mst)#instance 2 vlan 6-10
SW1#show spanning-tree mst 

##### MST0    vlans mapped:   11-4094
Bridge        address aabb.cc00.0100  priority      32768 (32768 sysid 0)
Root          this switch for the CIST
Operational   hello time 2 , forward delay 15, max age 20, txholdcount 6 
Configured    hello time 2 , forward delay 15, max age 20, max hops    20

Interface        Role Sts Cost      Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Et0/0            Desg FWD 2000000   128.1    Shr Bound(STP) 
Et0/1            Desg FWD 2000000   128.2    Shr 
Et0/2            Desg FWD 2000000   128.3    Shr 
Et0/3            Desg FWD 2000000   128.4    Shr 
Et1/0            Desg FWD 2000000   128.5    Shr 
Et1/1            Desg FWD 2000000   128.6    Shr 
Et1/2            Desg FWD 2000000   128.7    Shr 
Et1/3            Desg FWD 2000000   128.8    Shr 

##### MST1    vlans mapped:   1-5
Bridge        address aabb.cc00.0100  priority      32769 (32768 sysid 1)
Root          this switch for MST1

Interface        Role Sts Cost      Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Et0/0            Desg FWD 2000000   128.1    Shr Bound(STP) 
Et0/1            Desg FWD 2000000   128.2    Shr 
Et0/2            Desg FWD 2000000   128.3    Shr 
Et0/3            Desg FWD 2000000   128.4    Shr 
Et1/0            Desg FWD 2000000   128.5    Shr 
Et1/1            Desg FWD 2000000   128.6    Shr 
Et1/2            Desg FWD 2000000   128.7    Shr 
Et1/3            Desg FWD 2000000   128.8    Shr 

c.为不同组配置不同的根桥

SW1(config)#spanning-tree mst 1 ?
  priority  Set the bridge priority for the spanning tree
  root      Configure switch as root

d.查看mst配置情况

SW1#sh spanning-tree mst configuration 
Name      []
Revision  0     Instances configured 3

Instance  Vlans mapped
--------  ---------------------------------------------------------------------
0         11-4094
1         1-5
2         6-10
-------------------------------------------------------------------------------

六、EtherChannel  

1.作用:

a.将多条物理链路逻辑绑定,形成一条逻辑链路

b.负载均衡

c.感官上是一个逻辑端口

d.冗余

2.DTNP(Dynamic Trunk Negotiation Protocol)

a.PAgP(Port Aggregation Protocol)思科私有

b.LACP(Link Aggregation Control Protocol):802.3ad

3.配置

a.PAgP:auto(只收不发)、desirable(也收也发)、一边auto一边desirable可以建立连接

b.LACP:active(两遍都是可以建立连接)、passive(两遍都是不可以建立连接)、一边active一边passive可以建立连接

c.on

4.配置etherchannel的条件

5.负载分担

a.基于源MAC地址做负载分担

SW1(config)#port-channel load-balance ?
  dst-ip       Dst IP Addr
  dst-mac      Dst Mac Addr
  src-dst-ip   Src XOR Dst IP Addr
  src-dst-mac  Src XOR Dst Mac Addr
  src-ip       Src IP Addr
  src-mac      Src Mac Addr

 

SW1#sh etherchannel summary 
Flags:  D - down        P - bundled in port-channel
        I - stand-alone s - suspended
        H - Hot-standby (LACP only)
        R - Layer3      S - Layer2
        U - in use      f - failed to allocate aggregator

        M - not in use, minimum links not met
        u - unsuitable for bundling
        w - waiting to be aggregated
        d - default port


Number of channel-groups in use: 1
Number of aggregators:           1

Group  Port-channel  Protocol    Ports
------+-------------+-----------+-----------------------------------------------
1      Po1(SU)          -        Et0/0(P)    Et0/1(P)  

七、VTP安全

1.BPDU Guard 

a.一般做在接入层交换机

b.一般下面接PC,禁止此接口接受BPDU

c.如果此接口收到BPDU,就变为err-disable状态(类似down)

d.可以手动恢复、也可自动恢复

SW1(config-if)#spanning-tree bpduguard enable

e.自动恢复命令:

SW1(config)#errdisable recovery cause bpduguard

 

SW1#sh errdisable recovery 
ErrDisable Reason            Timer Status
-----------------            --------------
arp-inspection               Disabled
bpduguard                    Enabled
channel-misconfig (STP)      Disabled
dhcp-rate-limit              Disabled
dtp-flap                     Disabled
gbic-invalid                 Disabled
inline-power                 Disabled
l2ptguard                    Disabled
link-flap                    Disabled
mac-limit                    Disabled
link-monitor-failure         Disabled
loopback                     Disabled
oam-remote-failure           Disabled
pagp-flap                    Disabled
port-mode-failure            Disabled
pppoe-ia-rate-limit          Disabled
psecure-violation            Disabled
security-violation           Disabled
sfp-config-mismatch          Disabled
storm-control                Disabled
udld                         Disabled
unicast-flood                Disabled
vmps                         Disabled
psp                          Disabled
dual-active-recovery         Disabled

Timer interval: 300 seconds

Interfaces that will be enabled at the next timeout:

可以修改恢复时间:

SW1(config)#errdisable recovery interval 30

交换机所有接口都做BPDU防护:

SW1(config)#spanning-tree portfast bpduguard default

级联上行接口必须关闭bpduguard:

SW1(config-if)#spanning-tree bpduguard disable

2.BPDU filter

a.对收到的BPDU执行drop操作

SW1(config-if)#spanning-tree bpdufilter enable

其余命令类似guard

注意:guard不接受BPDU,但还发,而filter不接受也不发送

八、根桥防护(Root Guard)  

 

1.对于外部接进来且拥有更优BPDU的交换机,与其相连的接口配置root guard,端口会显示不一致状态,然后将此端口置为broken状态,如果过一定时间后没有再收到更优BPDU,则会自动打开

SW1(config-if)#spanning-tree guard root

九、防环

  

B和C之间通过两根网线进行收发,整个图中运行STP,稳定状态下C向B的发送端口为BLK状态,当B向C的网线断掉后,C收不到B发来的BPDU,过20s后C向B的端口变会变为LIS状态,此时,B向C的端口为DP,C会向B也发送BPDU,但为次优BPDU,B还是认为自己端口为DP,C因为收不到B的BPDU,也认为自己的到B 的端口为BPDU,此时整个网络就全通了,就形成了环路,主要是光纤口出问题。

1.单向链路出现问题,直接将整个端口BLK

SW1(config)#udld enable
SW1(config-if)#udld port

2.

SW1(config-if)#spanning-tree guard loop

建议配置在根端口或交替端口上

3.udld和loop区别

  

 a.loop能自动恢复,UDLD需要配置

 b.loop建议配置在根端口或交替端口上,UDLD建议在所有链路上配置

   c.loop是解决软件问题(端口拥塞、CPU忙),UDLD是解决硬件问题(网口坏了,线坏了)

  

 

  

  

  

  

  

  

  

  

  

  

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!