Showing posts with label Cisco. Show all posts
Showing posts with label Cisco. Show all posts

Friday, March 22, 2013

STP Enhancements Part 1





STP Enhancements Part 1 - BDPU Guard, BPDU Filter, BPDU Root Guard



BPDU Guard - BPDU is guarding your switch against BPDUs.  Wait, I thought BPDUs were a good thing?  Yes but only on ports uplinked to other switches, ports you expect to have BPDUs.

Why:  When you configure your switch to connect to hosts (PCs and Servers) you are probably using portfast.  If a user ever connected a switch, or some wires got crossed and a switch got plugged in to a host port, or a linux user enabled a software bridge etc. etc.... you could have a network loop 

What:  BPDU guard is a port setting that will shut down a port if it ever sees any BPDU

How:
Globally:
spanning-tree portfast edge bpduguard default
*make sure you disable bpduguard on the uplink ports you expect to have switches plug into: the global command affects all ports with portfast enabled*

Per Interface:
spanning-tree bpduguard enable


Recovery:  if BPDU guard triggers (sees a BPDU) it places the port in an error-disabled state, and the port is effectively shut down.  You can recover by (first removing the offending device), then logging into the switch, and issuing a shut command, followed by no shut.

If you would like the switch to be able to re-enable the port by itself, you can use error-disabled's regular methods:

errdisable recovery cause bpduguard
errdisable recovery interval 400

This will cause the switch to shut down the port for 400 seconds, then if it isn't receiving BPDUs, re-enable the interface.

*Note that BPDU Guard is triggered by BPDUs, so if a user plugs in a home/residential switch, it will not trigger as small home switches do not send BPDUs or participate in spanning tree at all.  This will not have any effect on home switches or hubs. (unless there is a loop and the cisco switch see's it's own BPDU sent back to itself, but then you already have a problem!)

BPDU Filter:

Why: Filter is slightly trickier as the global command and the interface command perform two different functions.  
1. First the interface method.  If you apply BPDU filtering to a specific interface, it effectively turns off spanning-tree.  
2. The global method is intended to save on bandwidth/proc overhead by not sending BPDUs out host ports.


What:
1. Interface Method: When turned on for a specific interface, that interface will ignore BPDUs sent to it, and it will not send any BPDUs.  It will continue forwarding traffic and not participate in spanning-tree.
2. In global mode: all interfaces in portfast mode will be put in filtering mode.  They will send out 10 BPDUs when the port comes up, and assuming no incoming BPDUs the switch will stop sending any BPDUs.  If a port ever receives a BPDU at any time, it will lose it's BPDU filter mode, removes the portfast status, and begins regular spanning tree listening/learning process.

How:
global mode
config)# spanning-tree portfast bpdufilter default

interface mode
(config-if)# spanning-tree bpdufilter enable


*note - enabling both BPDU guard and BPDU filtering on the same interface - BPDU filtering takes precedence and BPDU guard has no effect

Root Guard:


Why: ensure an interface will never be used as a root port, increasing STP stability.  Now at first it is tempting to think you should add root guard to all non-root ports but don't forget, you have a redundant topology for a reason.  You need your STP domain to be able to reconverge in the case of a failure and elect a new root bridge/use a different root port.  When you choose what ports get root guard, take into consideration any paths you might ever want your traffic to traverse and do not implement root guard on them.  The easiest and preferred way might be to just use this on edge/access ports and leave it off for all switch-to-switch connections, but perhaps your topology has a "leaf loop" off of your primary STP loop that you never want to use as an STP root, and would rather stop forwarding traffic than allow a switch out there to become root... maybe.

Anyway, root guard is designed so that if anyone plugs a new or non-corporate switch into your network, and it happens to have a low priority, it won't become root.


What:  If the root guard port receives a BPDU with superior priority to what the LOCAL switch is seeing (not the root's own priority) the port will move to a "root-inconsistent state" and stop forwarding traffic.  If the switch is removed or the priority is raised, the port will move out of root inconsistent state on it's own and begin forwarding traffic (after moving through listening/learning states).  No user intervention or config changes needed to unblock the port.

This feature does not have a global function, only a per-interface function.


config# int fa0/2
config-if)# spanning-tree guard root


*note - if you are just enabling this on host ports to protect your STP topology, just use BPDU guard instead.  The only useful time I can think of using root guard: if you want to create a policy that all un-used uplink ports have root guard configured to protect the topology.  When a new switch is added the root is protected, and once the switch is up and operational you can remove the root guard feature.

Spanning Tree Portfast



Portfast - didn't think I would have enough for a whole post, but there are a few items worth mentioning.


What is it - Typically, if a host (server, PC, etc.) plugs into a port, spanning tree will run to ensure there is not a network loop before allowing the host to talk.  If you are running the default, Cisco per-vlan spanning tree 802.1d, this takes 30 seconds for both listening and learning mode to run.

The problem - Thirty seconds is a long time to wait, especially when it means you are not getting DHCP responses and your computer is deciding that it must not be on a real network so it doesn't need to run all the network startup scripts.

The solution - configuring portfast on an interface tells that switch that only a host (nothing that could cause a loop) is connected.  The switch then allows the port to immediately transition to forwarding (but will loose it's portfast status if a BPDU is recieved)

The dangers - if you mis-configure this, and turn portfast on for an uplink to another switch, hub, etc. a loop could form and crash your network before spanning tree ever has a chance to prevent it.

The terms:  in rapid spanning tree protocol (802.1w) they are called "edge ports" but are still configured with the same portfast command. 

The commands:

interface fa0/1
spanning-tree portfast
exit

or

interface fa0/1
switchport host
 *This turns on portfast and also disables channeling and trunk negotiation*

or globally from privileged exec mode

#spanning-tree portfast default
*In the global form of portfast, immediate forwarding is enabled for all access ports (NOT ANY TRUNK PORTS) but you should still manually input the command no spanning-tree portfast for any ports that may be connected to other switches*


spanning-tree portfast trunk
*This command is to turn portfast on for a trunk.  You would typically have a trunk enabled for a host such as a server that needs multiple vlans, or a VoIP phone*


If a BPDU is ever recieved on an edge/portfast port, it loses it's portfast status AND sends a Topology Change Notification to all other switches in the STP domain.





Wednesday, July 14, 2010

STP Topology Change Notifications

Q1. What is the purpose of spanning tree portfast?

A. Well, the noticeable part is from the client's view. Portfast means the port does not move through the listening and learning states (30 seconds) which can mean delayed, slow, and even missed startup scripts.

The (arguably) more important point is the affect on your network. Every time a port comes out of blocking and moves to listening, learning, and forwarding, a topology change has occured. The switch sends a Topology change notification to the root switch and EVERY switch in your STP topology will shorten their cam table aging time to the forward delay time (default 15 seconds). This means every device in your STP network that isn't very chatty will have their mac flushed from the switch and need to be relearned. So moral of the story, use portfast on every client port to prevent a whole lot of spanning tree traffic and cam table flushes.


Q2. So describe this Topology Change Notification Process

A. Ok, a port on a switch changes state (we are assuming it is not in portfast mode), so a link comes up or a forwarding port goes down. The switch immediately sends a Topology Change Notice (TCN) out it's root port. (unless the root port was the link that just went down, then the switch will sit and wait to hear from the root or attempt to make itself root) All switches that receive the TCN forward it toward the root.

Once the root receives the TCN, first it sends an acknowledment to the originating switch, then it creates a packet with the Topology Change Bit Set, to notify all switches that there has been a topology change. This is flooded to all switches in the topology. When each switch sees the packet with the topology change bit set, it will lower it's bridge table aging time to the forward delay timer and pass on the topology change packet down the tree. The cam table flush is because the changing topology can mean mac addresses will be appearing on new interfaces. The switches don't yet know how the topology has changed, just that they need to flush any unused mac addresses to prepare for a change.

Ports will go through their regular STP states to create a new topology if one is required.


Q3. When does a port come out of blocking state?

A. If no BPDU (bridge protocol data units, how switches communicate STP) arrives within the max age time, OR if a port receives a BPDU with a better root "cost".

Remember, If a port is not a root port or a designated port, it will be in blocking.


Q4. How often are BPDUs sent

A. By default, 2 seconds

Thursday, July 8, 2010

Local Area Mobility

So networking companies have been trying to sell us ways to extend layer 2 networks for many years now, back in the days with brouters, Shortest Path First Switching, and even new technologies just out in the last few months such as TRILL and OTV. Now I haven't looked into the new technologies enough to give a thumbs up or down, but since everything in the past has had so many problems I am skeptical.

Looking into it a little though I run into an old gem from the mid 90s (the whitepaper talks about how the new windows 95, with a DHCP client installed, can automatically get an IP address!). Local Area Mobility. Now this may not scale well, but for the problem of a few servers needing to be in the same subnet but a different physical location it works great. In fact it is so simple it blew my mind that I had never heard about or thought of such a thing.

The key is simply that routers use the longest prefix to determine a route. Solution - Host routes.

Local Area Mobility, when turned on, will listen and when a computer is turned on with a statically set IP address that doesn't match the interface's subnet, the router injects a host route (/32) into the routing table. It will also proxy arp requests so that clients in the same subnet (but different router) can still communicate. User attempts to connect to the server's IP, router looks up and finds the /32 hostroute preferred over the /24 or whatever and the packet is properly sent to the server.

I don't know why but that is still blowing my mind how simple it is.

http://www.cisco.com/en/US/products/ps6590/products_white_paper09186a00800a3ca5.shtml

Monday, June 28, 2010

EIGRP Equal and UnEqual cost load balancing

By default, EIGRP load balances across up to 4 equal cost paths. EIGRP can also load balance over unequal cost paths as well.

1. How do I turn off EIGRP load balancing?

A. maximum-paths 1

2. How do I load balance over 16 paths

A. maximum-paths 16

3. I set up load balancing and am trace-routing the destination from my console, but it is only using one path

A. Load balancing is performed only on traffic passing through the router, not router generated traffic

4. I want to set up unequal cost load balancing, what do I do?

A. First you must determine the variance you wish to use. Take your FD (Feasible Distance) of your best route. Now what number do you need to multiply it by to include the FD of all other routes you wish to load balance across?
For instance, if your successor, or best route, has a FD of 10, and you want to load balance across paths with costs of 15 and 20, choose a variant of 2. Then, all FDs 20 or under will be included in unequal cost load balancing. If you wanted to load balance across a 25, choose a variance of 3 to include all FDs under 30. (*Note* to avoid loops, the FD of routes must also be less than the advertised distance of your successor route. Read my last post for more on this)

traffic-share balanced
variance [#]

5. The load balancing command also has a minimum command, when would I use that?

A. The traffic-share min across-interfaces command is used for OSPF and other protocols to turn on equal-cost load balancing. If you have changed to unequal cost load balancing you could use this to return to equal cost in EIGRP. This command will leave all of your variance chosen paths in the routing table (see #4) but packets will only be routed out the paths that are the least cost (minimum) route(s).