Sunday, January 24, 2010

BCMSN Lab - Basic Switch Configuration IV [CCNA Rev]

Spanning-Tree Protocol (STP), Per-VLAN Spanning Tree Protocol, (PVSTP), Rapid Spanning-Tree Protocol (RSTP) and Per-VLAN Rapid Spanning Tree Protocol (PVRSTP)

Should be knowing by now as to what all the above are, what their purpose is and the difference between each of em'.

For those who don't, kindly resit your CCNA. Spanning Tree in a nutshell is implemented for redundancy. Most Cisco switches have STP enbled by default. It's usually the low-end switches (Alcatel, etc) ones not at the entreprise level that don't come with STP. Anyway the switch basically uses BPDU's to detect a loop in the network. If the BPDU arrives back to the switch, the switch realises that there's a loop and shuts off one of it's ports. That port is the one which is 'blocked' (for stp) or 'alternate' (rstp) port.

The root port is located on the 'Root switch' or the primary switch which is the one having the lowest Bridge ID. Bridge ID = Priority + Mac-Address. Lower= better in spanning-tree. The default priority value on all cisco switches is set to '32768'. Obvious fact-of-the-day : the newer the switch the higher the Mac-Address value, thus you never want to leave stp running on it's default options. The highest port (eg: fa0/2 over fa0/1) in use on the switch that has the highest Bridge ID gets blocked.

That was a 2min brainstorm of STP. There's a lot more to it, but I assume anyone studying for CCNP is well-versed and familiar with most of its concepts.

In this post, I'll be configuring those 3 switches in Packet Tracer for STP first and later for RSTP on VLAN's 10, 20, 30.

We'll configure S2 as the primary root switch. Step 1 is to see if spanning-tree is running via executing the 'show spanning-tree' command. Step 2 is to lower the priority on the primary switch that you want as root to lower the bridge id.

Configuration: STP

S2#show spanning-tree
S2#conf t
S2(config)#spanning-tree vlan 10 root primary (method 1 - lowers the priority from 32768 to the IEEE recommended value)
or
S2(config)#spanning-tree vlan 10 priority 4096 (method 2 - set priority manually - in increment/decrements of 4096)

I prefer the second method so:

S2(config)#spanning-tree vlan 20 priority 4096
S2(config)#spanning-tree vlan 30 priority 4096

At this stage we don't need to go on the other switches and increase the priority as remember the default is 32768)

and that's all there is to base configuration of STP (in a not so complex-network)...

STP: Limitations

There are some problems with spanning-tree though. As STP was created a long time ago, it takes quite a while for the backup link to activate itself:

(1) Listening - 15 seconds of listening for BPDU's (Switch sends and receives BPDU's)
(2) Learning - 15 seconds of learning mac-addresses (Populates switch CAM table)
(3) Forwarding - Port is forwarding traffic.
(4) Blocking - BONUS - Switch will wait upto 20 seconds (max-age) before moving a blocked port into listening phase) - If the link fails then the blocking timer gets activated.

i.e: it waits for 20 secs to see if the link comes back up, if it doesn't, it goes into listening mode (+15 secs = 35 secs) then goes into learning mode (+15 secs = 50 secs!) that's 50 seconds of downtime on each port before the link comes up!

STP: Solution - Portfast and Rapid STP (802.1w)

Step 1 - Enable Portfast for RSTP to work.

Portfast - Portfast is a tool that essentially turns off spanning-tree on your switches, so the port will become active as soon as you plug in but that will cause loops in the network.

Rapid STP - In STP, STP forgets the blocked port, hence once the main port goes down, it waits for a certain amount of time, listens, learns and then forwards the port thus wasting much time in the process.
With Rapid STP, In Rapid STP there are no 'blocked' ports instead they are 'Alternate' ports. RSTP sees the backup ports as just that; backup. Meaning unlike STP, RSTP remembers them.

The catch with RSTP is that it's a fairly new standard and so in-order for rapid spanning-tree to work, you have to have it running everywhere which means major upgrading. You can't even have one switch that doesn't have RSTP else it slows the whole network down.

STP vs. RSTP

STP:

Root port - Used to reach the root bridge

Designated Port - Forwarding port. One per link.

Blocked Port - Where the tree falls.

RSTP:

Root port - Used to reach the root bridge

Designated Port - Forwarding port. One per link.

Alternate Port - Discarded port. Backup path to root.

Note: Cisco also supports Rapid STP per VLAN just like PVSTP.

Configuration: RSTP

Step 1 - Lower priority on Root switch
Step 2 - Change spanning-tree mode to Rapid PVST (in global-config mode)
Step 3 - Enable portfast (on all interfaces participating in PVRSTP)

Step 1:

S2#show spanning-tree
S2#conf t
S2(config)#spanning-tree vlan 10 priority 4096
S2(config)#spanning-tree vlan 20 priority 4096
S2(config)#spanning-tree vlan 30 priority 4096
S2(config)#exit

Step 2:

S2(config)#spanning-tree mode rapid-pvst

Step 3:

S2(config)#int-range fa0/1 - fa0/2
S2(config)#spanning-tree portfast
S2(config)#end
S2#wr

(Similar config on S1 and S3. Note: int fa0/1 and fa0/2 are trunk ports connecting to the two other switches).

More on spanning-tree in the next post...

No comments:

Post a Comment