BGP Path Selection

BGP Path selection relies on the BGP attributes. I have described the eight most important BGP attributes in my previous BGP Basic Information post.

Weight: The path with the highest weight is preferred. This is only locally significant and not affect any other router within the AS. Cisco only, used for outbound path selection

Local Preference: The path with the highest local preference is preferred. This is not locally significant and will affect other routers in the same AS. Used for outbound path selection

Originate: A path that originated on the local router is preferred to any paths learnt from a BGP peer. Cisco adds a weight of, 32768 to any prefixes advertised into the local router.

AS Path: The shortest AS path is preferred. Used for inbound path selection

Origin: Where was the path learnt from originally; IGP, INCOMPLETE. IGP via network statement and INCOMPLETE via a redistribution command. IGP is preferred to INCOMPLETE.

Multi-Exit Discriminator (MED): Lowest MED is preferred. Only performed if the first hop AS is identical. If the first hop is different, then this is skipped.

Paths: By default, only a single path is installed into the routing table. This can be changed using the maximum-paths command in Cisco and Arista.

Router ID: Compare the router ID of the peer that the path is learnt from. Lower is preferred.BGP Synchronisation

I’ll go over a few of these attributes with labs

Topology

I have created a small 4 router topology that I will be using to change different attribute parameters.

Weight/Router ID

  • The weight is a Cisco proprietary attribute
  • Weight is not exchanged between routers
  • Local to the router
  • Highest weight is the preferred path

In this example, there are is a network 200.0.0.1/32 that R1 would like to connect to. There are two direct paths, one via ISP1 and another via ISP3.

Update message sent from ISP3 to R1 containing the directly connected networks known. Network 200.0.0.1/32 is in there.

Back on the R1 routing table, the routes are shown.

Adding the same redistribute connected to ISP1 will also advertise 200.0.0.1/32 to R1. Once that has been advertised, to R1, R1 has updated its routing table to show the route to 200.0.0.1/32 is no via ISP1.

ISP1 has replaced ISP2 as the preferred path because of the neighbour id is lower on ISP1 1.1.1.1, compared to ISP2 2.2.2.2.

I have modified the router ID on ISP1 to be 1.1.1.2 and ISP3 to be 1.1.1.1. The peers have been reset and the routes have been relearnt. This time, however, the route is pointing via ISP3, 2.2.2.2.

Now that ISP2 is the preferred route for the network 200.0.0.1. I will change the weight to make ISP1 the preferred route and clear the BGP neighbours to start fresh again.

Local Preference

  • Can be used to choose the outbound external BGP path
  • It is sent to all iBGP peers in the same AS
  • No exchanged between eBGP peers
  • Default attribute is 100
  • Highest is preferred

The topology has changed. There is no iBGP in AS 65001 and the connections to ISP1 and ISP3 have been moved to the new R2 and R3 routers in AS 65001.

The networks learnt via ISP1 and ISP3 have been advertised into iBGP. As there is not a full mesh or route reflector, only R1 will learn about all the networks.

I have added the command to R2 and R3 so that R1 will know how to reach the next hop ISP routers.
R3(config-router)#neighbor 10.10.13.1 next-hop-self
R2(config-router)#neighbor 10.10.12.1 next-hop-self

The network 200.0.0.1 is learnt via both ISP1 and ISP3. Only the route via ISP1 is installed in the routing table.

To modify this, local preference will be used to prefer ISP3 over ISP1. I have first set this on R1 with a prefix list and route map. This has been successful in changing the route to go via ISP3.

This next change, I would like to see the local preference propagated inside the AS. I have moved the route map to R3, applying the local preference of 150 as the route is learnt from ISP3.

This has been successful, as shown on R1.

AS Path

The last attribute I will go over is the AS path. This is for advertising networks to external BGP peers. In this topology, I will advertise a network of 100.123.10.0/24 that is owned by AS 65001. This network will be advertised to both ISP1 and ISP3.

ISP2 will learn about the network 100.123.10.0/24 from both ISP1 and ISP2 and decide which is the preferred path.

ISP2 has learnt about all the routes now, specifically 100.12.10.0/24. The best path for this route is via ISP1, which is expected due to the best path being chosen based on router ID.

On router R2 I will prepend AS 65001 that will make it look as though there are more AS’ to pass through that via R3.

After the change, the routes learnt via BGP can see that all routes from R2 have the AS 65001 prepended. This could have been narrowed down to only the network 100.123.1.0/24 with the use of a prefix list. However, as this is just a lab, I have left it. But it does highlight the importance of being as specific as possible with BGP.

The route now chose is via ISP3.

Leave a Comment

Your email address will not be published. Required fields are marked *