Difference Between BGP & IGP Path Selection BGP (Border Gateway Protocol) routers usually receive multiple paths to the same destination. BGP however, selects the best path based on a set of attributes. IGPs select the path with the lowest metric. For example: RIP selects the path with the lowest hop count. OSPF selects the path with the lowest cost. EIGRP selects the path with the highest bandwidth and lowest delay (unless you change the K values).
How to know about best path in BGP?
Path is selected based on the following attributes Priority Attribute 1 Weight 2 Local Preference 3 Originate 4 AS path length 5 Origin code 6 MED (MULTI_EXIT_DISC) 7 eBGP path over iBGP path 8 Shortest IGP path to BGP next hop 9 Oldest path 10 Router ID 11 Neighbor IP address
Quick overview of Each Attribute (1 of 3) Weight: Prefer the path with the highest weight. This is a value that is local to the router and it’s Cisco proprietary. The default value is 0 for all routes that are not originated by the local router. Local Preference: The local preference is used within an autonomous system and exchanged between iBGP routers. We prefer the path with the highest local preference. The default value is 100. Originate: Prefer the path that the local router originated. In the BGP table, you will see next hop 0.0.0.0. You can get a path in the BGP table through the BGP network command, aggregation, or redistribution. A BGP router will prefer routes that it installed into BGP itself over a route that another router installed in BGP. AS path length: Prefer the path with the shortest AS path length. For example, AS path 1 2 3 is preferred over AS path 1 2 3 4 5.
Quick overview of Each Attribute (2 of 3) Origin code: Prefer the lowest origin code. There are three origin codes: IGP, EGP, INCOMPLETE. IGP is lower than EGP and EGP is lower than INCOMPLETE. MED (MULTI_EXIT_DISC): Prefer the path with the lowest MED. The MED is exchanged between autonomous systems. eBGP path over iBGP path: Prefer eBGP (external BGP) over iBGP (internal BGP) paths. Shortest IGP path to BGP next hop: Prefer the path within the autonomous system with the lowest IGP metric to the BGP next hop.
Quick overview of Each Attribute (3 of 3) Oldest Path: Prefer the path that we received first, in other words, the oldest path. Router ID: Prefer the path with the lowest BGP neighbor router ID. The router ID is based on the highest IP address. If you have a loopback interface, then the IP address on the loopback will be used. The router ID can also be manually configured. Neighbor IP address: Prefer the path with the lowest neighbor IP address. If you have two eBGP routers and two links in between then the router ID will be the same. In this case, the neighbor IP address is the tiebreaker.
BGP Weight Attribute
About BGP Weight Attribute (1 of 2) BGP weight attribute is a Cisco proprietary path attribute that is local to the router and is used to influence local path selection on a certain router. BGP weight is the first tie breaker for best path selection on a Cisco router, the attribute is not propagated to other routers in the BGP updates and only found on Cisco routers. The path with the highest weight is selected as the best toward a destination.
About BGP Weight Attribute (2 of 2) The weight can be a number from 0 to 65,535. Paths that the router originates have a weight of 32,768 by default, and other paths have a weight of 0. As we mentioned earlier the path with the highest weight value wins. BGP weight can be set using three ways on a Cisco router. Those are: assigned per neighbor, using AS-Path access lists, using route-maps (complex). BGP weight is the easiest way to manipulate the BGP path selection on a single Cisco router for outbound traffic. The attribute is local and will not be propagated to other routers in the network within the BGP update messages.
BGP Weight Attribute Assigned per neighbor (1 of 4) R1 to get to R6 it has chosen the path through R4- When both paths are external prefer the oldest one – This is the tiebreaker!
BGP Weight Attribute Assigned per neighbor (2 of 4) To prove that we can restart the bgp process on R4 to make R5 the oldest route. On R4 I have done a clear ip bgp * This now makes the route through R5 the oldest one and is preferred.
BGP Weight Attribute Assigned per neighbor (3 of 4) Under BGP enter the following command – neighbor 10.0.14.4 weight 100
BGP Weight Attribute Assigned per neighbor (4 of 4) You will also notice that all prefixes received from R4 have also had their weight changed to 100
BGP Weight Attribute Using AS-Path access lists (1 of 2) For this example we only want to set the weight for the 6.6.6.6/32 prefix. First we need to match this prefix in an access list This is now applied to the neighbor statement for R4 – we also need to remove the previous weight attribute
BGP Weight Attribute Using AS-Path access lists (1 of 2) You can see now that we have changed the weight attribute for the 6.6.6.6/32 prefix only. All other routes have the default weight of 0.
BGP AS-Path Prepending
About BGP AS-Path Prepending AS-Path prepending is a way to manipulate the AS-Path attribute of a BGP route. It allows prepending multiple entries of AS to a BGP route. This can come as a workaround if a specific path is required to be followed, and other means like Multi-Exit Discriminator (MED) is not supported. AS-Path prepending can be applied to inbound and outbound direction using route-maps.
Outbound AS-Path Prepending (1 of 2) AS-Path prepending can be applied to outbound direction on R3 router as below- Outbound AS-Path prepending on R3-
Outbound AS-Path Prepending (2 of 2) When R3 router advertises its 10.1.1.0/24 network to R2 router, it prepends its own AS 200 multiple times. However, R1 router receives the original BGP route with a single AS-path entry. BGP tables on R1 and R2- R2 router has two paths to 10.1.1.0/24. However, it chooses the path through R1 since that path has shortest AS-Path (indicated by a > sign, meaning best route). Hence, the direct path through R3 router can act as a backup path.
Inbound AS-Path Prepending (1 of 2) Inbound AS-Path prepending is configured using set as-path prepend last-as command under route-map which is then applied in inbound direction. The last-as keyword copies the AS number of the neighbor advertising the BGP route that matches the route-map. Inbound AS-Path prepending on R1-
Inbound AS-Path Prepending (2 of 2) This configuration causes R1 to prepend the AS number of R3 twice before installing in the BGP table. As seen below, R3 does not prepend any AS number by itself. BGP tables on R1 and R3-