Jaycee's Networking

April 23, 2009

BGP Path Selection – IOS

Filed under: BGP, IOS — Tags: — Jaycee @ 11:31 pm

1. Next-Hop accessible:

By default, routers don’t update the next-hop attribute when exchanging routers by iBGP. BGP will not pass unreachable routes to the main routing table, but it will keep them in its own route database.

*NEXT_HOP is mandatory attribute that carries the IP address of the 1st BGP router along the path to the destination network. By default, the NEXT_HOP router will be the router that announced this route to the AS. For routes learned from an external AS via eBGP, the NEXT_HOP router will be the 1st router in the neighboring AS. This information is passed intact throughtout the AS using iBGP, so all routers in the AS se the same NEXT_HOP router.

2. Synchronization:

Synchronization means that a BGP router is not allowed to advertise a route that is learned from another BGP peer until the router knows about the route via an IGP.

If synchronization is enabled, the router will ignore any iBGP routes that are not synchronized. Because the AS needs to behave consistently, if you run an IGP and iBGP, they have to agree.

For a BGP route to be usable, the IGP must also contain a route to the same prefix. This ensures that one of these BGP peer routers doesn’t try to forward a packet to the other internal BGP peer unless the network connecting them knows what to do with this packet.

Synchronization requirement: Asserts that a route must be known by an IGP before it may be advertised to BGP peers.

Disabling synchronization is an absolute MUST for running iBGP: Cisco routers allow to disable synchronization, which is necessary in any case where you dont redistribute the IGP routes into BGP.

Synchronization can be disabled safely under either of 2 conditions:

(1) If your network doesn’t pass traffic from one AS to another (i.e., other networks do not route their traffic through you.)

(2) If all your border routers are running BGP.

router bgp 65500
 neighbor remote-as 65501
 no synchronization

3. Weight (Influences OUTBOUND traffic, but apply on inbound) :

This is Cisco proprietary parameter given to a route on a particular router and is used only within that router. The weight is never given to other routers.

*Default weight = 0, except for locally sourced routes which get a default weight = 32,768. The maximum weight is 65,535.

*Weight value => the higher the better.

router bgp 65500
 no synchronization
 bgp log-neighbor-changes
 bgp dampening
 network mask
 neighbor remote-as 65510
 neighbor weight 200
 no auto-summary

4. Local Preference (Influences OUTBOUND traffic, but apply on inbound) :

Routers only include LOCAL_PREF attribute when communicating within an AS (iBGP).

(1) For external routes, the router that receives a particular route via eBGP sets sets the Local Preference value.

(2) For internal routes, it’s set by the router that introduced the route into BGP.

This allows you to force every router in your AS to preferentially send traffic for a particular destination through a particular eBGP link.

Local preferences are shared among iBGP routers, but they are NOT shared with external BGP routers.

*Default Local_PREF = 100.

*Local_PREF value => the higher the better.

*LOCAL_PREF is discretionary attribute.

router bgp 65500
 no synchronization
 bgp log-neighbor-changes
 bgp dampening
 network mask
 bgp default local-preference 200
 neighbor remote-as 65510
 neighbor route-map LOCALPREF in
 no auto-summary

route-map LOCALPREF permit 10
 match ip address prefix-list LOW_LOCALPREF
 set local-preference 50
route-map LOCALPREF permit 20

ip prefix-list LOW_LOCALPREF seq 10 permit

5. Self-Originated:

BGP routes prefer routes that originate inside their own AS.

6. AS Path (Influences INBOUND traffic, but apply on outbound) :

For routes that originate outside of the AS, BGP will prefer the one with the shortest path. AS paths allow BGP to detect routing loops.

*AS_PATH is mandatory attribute. There are 2 types of AS_PATHs:

(1) An AS_SEQUENCE describes the literal path taken to reach the destination
(2) An AS_SET is an unordered list of ASNs along the path.

*AS_PATH value: the shorter the better

ip as-path access-list 10 permit ^65501$
ip as-path access-list 20 permit _65530_
ip as-path access-list 20 deny _65531$
ip as-path access-list 20 permit .*

router bgp 65500
 no synchronization
 network mask
 neighbor remote-as 65510
 neighbor filter-list 10 in
 neighbor remote-as 65520
 neighbor filter-list 20 out
 no auto-summary

.*” permits all other AS Paths
“^$” the filed is empty

ip as-path access-list 10 permit ^$

route-map PREPEND permit 10
 match as-path 10
 set as-path prepend 65501 65501 65501
route-map PREPEND permit 20

router bgp 65501
 neighbor route-map PREPEND out
no auto-summary

7. Origin:

BGP selects IGP routes in preference to EGP, and EGP in preference to INCOMPLETE routes. An INCOMPLETE route is one that is injected into BGP via redistribution.

*ORIGIN is mandatory that have 3 different values:

0 – IGP
1 – EGP
2 – Incomplete

8. MED (Multi-exit discriminator) (Influences INBOUND traffic, but apply on outbound) :

BGP selects the route with the lowest MED value. MED actually leaves your AS and tells your neighbor routers which link we want them to talk to. That is, you use the MED to tell your ISPs which of serveral entrances to your network they should use. You should use MED values ONLY IF you are multihomed to a single provider.

MED is used ONLY if both routes are received from the same AS, or if the command “bgp always-compare-med” has been enabled.

With “bgp always-compare-med” enabled, BGP will compare MED values even if they come from different ASes, althought to reach this step the AS_PATHs must have the same length. You should use this command throughout the AS or you risk creating routing loops.

MED values are ONLY propagated to adjacent ASes, so routers that are further downstream dont see them at all.

*Default MED = 0.

*MED value => the lower the better

access-list 10 permit

route-map MED permit 10
 match ip address 10
 set metric 100
route-map MED permit 20

router bgp 65500
 neighbor MED out

9. External :

BGP prefers eBGP to iBGP paths which helps to eliminate loops. iBGP routes don’t include internal routes that are sourced from within your AS, because they are selected at step 5. This test only looks at routes to external destinations.

EBGP metric = 20 is lower than other IGP beacause it should go out of the AS instead of staying in AS.

iBGP metric = 200 is higher than other IGP because if it’s an internal route, it should use internal IGP.

10. IGP Cost :

BGP compares the IGP costs of the paths to the next-hop routers, and selects the closest one. This ensures that faster links and shorter paths are used where possible.

11. eBGP Peering/Ages of the routes :

BGP will look at the ages of the routes and use the oldest route to particular destination for stability.

12. Router ID :

BGP resorts to the router IDs of the next-hop routers by selecting the next-hop router with the lowest router ID. Router IDs are unique which guarantees to eliminate any remaining duplicate route problems.

A router’s ID is the IP address assigned to the loopback interface or the highest IP address on an active interface at boot time.

*Router ID => the lower the better



  1. Hi, interesting post. I have been thinking about this topic,so thanks for posting. I will definitely be subscribing to your site.

    Comment by How I Lost Thirty Pounds in Thirty Days — May 3, 2009 @ 9:50 pm

  2. If only I had a greenback for each time I came here! Amazing post!

    Comment by Jaclyn Solano — May 28, 2010 @ 9:15 am

  3. Really interesting read! Really.

    Comment by Beau Daugherty — May 29, 2010 @ 4:25 pm

  4. If only I had a quarter for every time I came to jayceechou.wordpress.com… Great post!

    Comment by Berry Hurd — May 30, 2010 @ 8:40 am

  5. Incredibly interesting read! Really!

    Comment by Betty Snider — May 31, 2010 @ 11:10 am

  6. Very awesome post. Honestly..

    Comment by Gregory Romero — May 31, 2010 @ 9:52 pm

  7. Can you recommend the best Patch Management script out there?
    I did my research on the web and got the following:

    They all look different… Does anyone can recommend any other?
    In addition did anybody hear of this:
    N-able remote system management software ?

    Comment by slolepelia — June 10, 2010 @ 9:22 am

  8. Very NICE — thank you

    Comment by Jack Cool — August 14, 2012 @ 8:24 pm

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Blog at WordPress.com.

%d bloggers like this: