BGP: Advanced Tuning using the known Attributes


BGP is all about tuning. The non-tuned BGP is basically a RIP, but once you adjust it to your needs - no other routing protocol can come even close.

The basic and well-known BGP Tuning Attributes are:


1. AS-Path (The less ASs in the path - the Better)

Used to influence another AS by adding or PREPENDING the AS's to the prefix using the Route Map.

You can do a pretty granular control here using the AS-PATCH Access Lists. You do need a basic knowledge of TCL for this, so basically if you need to match all the prefixes that pass threw the AS 65505 you do this:

(config)#ip as-path access-list 10 permit ^65505$ <--- you can go wild with the filters
*in this case we are filtering the prefixes origineted and advertised directly by AS 200


The AS-PATH ACL can also be applied to a neighbor as a FILTER-LIST

(config-router)#neighbor 172.25.185.45 filter-list 10 in



REMINDER of the META Characters:

^ - START of Line
$ - END of Line
| - Logical OR
_ - ANY DELIMETER
? - ZERO instances of the PRECEDING character
* - ZERO OR MODE instances of the PRECEDING character
+ - ONE OR MORE instances of the PRECEDING character
(x) - Combine the enclosed String as a single entity
[x] - Wildcard where any position can match the position in AS-Path
. - Any Character

After this you just match this condition in the route-map in order to set some parameter later:

(config-route-map)#match as-path 10


2. Weight (the Higher - the Better)

It's a CISCO Proprietary Attribute, Used ONLY LOCALY to influence the LOCAL AS by assigning the WEIGHT attribute to prefixes announced from a BGP Neighbor

First you need to set up the route-map. You can use the MATCH condition, but you dont have to. In this case we will apply the weight to all the prefixes announced by a neighbor.

route-map SET_WEIGHT permit 10
 match ...
 set weight 500

And now apply the route-map to a neighbor in the INBOUND direction (prefixes coming IN, meaning - are announced by that neighbor):

router bgp 65535
 neighbor 172.21.12.2 remote-as 64500
 neighbor 172.21.12.2 route-map SET_WEIGHT in

Or you can simply apply the WEIGHT attribute to the neighbor directly:

router bgp 65535
 neighbor 172.21.12.2 remote-as 64500
 neighbor 172.21.12.2 weight 500

3. MED (Multi Exit Discriminator) Attribute; RFC 1771 - Optional and Non-Transitive; The Smaller the Better

This is the most similar Attribute to the OSPF Metric that there is in BGP. The nature of this attribute is similar to the AS-Path, because they are both used to influence the other AS by tuning the attributes of the Locally Originated&Advertised Prefixes
You can simply set it (set metric X) within the route-map configuration, and apply it to the BGP Neighbor in the OUTBOUND direction

If you wish to RE-ARRANGE the Attribute Comparison order, and for example wish to compare the MED value before the AS-Path (meaning - prefer the lower MED, regardless of the AS-Path), you can use this command under the BGP configuration:

(config-router)#bgp always-compare-med <--- to compare MED value even if there is higher ranked attribute that decides
(config-router)#bgp bestpath as-path ignore <--- to IGNORE the AS-Path attribute, HIDDEN COMMAND on IOS!!!
*BE CAREFULL with the second command, the TAB key will not work and the "?" will not show you the "as-path" option

By default the MISSING MED value is considered the BEST one because on most IOS-s it picks up the value 0. To change this use:

(config-router)#bgp bestpath med missing-as-worst <--- Treat the non-defined MED as the WORST

No comments:

Post a Comment

Most Popular Posts