CiscoCCNPEnterprise NetworkingIntermediate22 min read

What Is BGP Best Path Selection in Networking?

Also known as: BGP Best Path Selection, BGP path selection attributes, CCNP ENCOR BGP, BGP weight local preference, Cisco BGP best path algorithm

Reviewed byJohnson Ajibi· Senior Network & Security Engineer · MSc IT Security
On This Page

Quick Definition

When a router learns multiple paths to the same network, it must decide which one to use. BGP Best Path Selection is the step-by-step decision process that picks the single best path. The router compares attributes like path length and origin type to make the choice. This ensures traffic follows the most preferred route according to the network administrator's policy.

Must Know for Exams

In the Cisco CCNP Enterprise certification, particularly the ENCOR (350-401) exam, BGP Best Path Selection is a core topic. The exam blueprint explicitly includes objectives related to BGP path selection, attributes, and manipulation. Candidates are expected to understand the order of operations and be able to identify which path a router will choose given a set of attributes.

Exam questions often present a table with multiple BGP routes for the same prefix, each with different attribute values. The candidate must step through the algorithm to determine the winner. For example, a question might show routes from different peers with varying Local Preference and AS_PATH length.

The candidate must know that Local Preference is checked before AS_PATH. If two routes have the same Local Preference, the one with the shorter AS_PATH wins. The ENCOR exam also tests configuration commands like set weight, set local-preference, and set metric (MED).

Candidates must know how these commands affect the selection process. Additionally, the exam may include scenario-based questions where a network is experiencing suboptimal routing, and the candidate must identify which attribute to modify. For instance, if traffic from a remote site is going over a slow backup link instead of a fast primary link, changing Local Preference on the primary link can fix it.

The CCNP Enterprise exam emphasizes practical knowledge, so understanding how to apply best path selection in real topologies is key. Beyond ENCOR, BGP topics appear in the ENARSI (300-410) and SPCOR (350-501) exams. In ENARSI, candidates dive deeper into advanced BGP features and troubleshooting.

Questions may involve complex redistribution scenarios or BGP communities. For all these exams, memorizing the attribute order is not enough; candidates must understand the why behind each attribute and how it interacts with others.

Simple Meaning

Imagine you are a post office worker in a large city, and you have a letter that needs to reach a specific address across town. You check the map and see several possible roads you could take to get there. Some roads are shorter, some are wider, some have fewer traffic lights, and some are preferred because they are part of an official postal route.

You need to pick the single best road to use. BGP Best Path Selection is exactly that decision process, but for routers sending data across the internet. A router, like you, may know multiple paths to reach a destination network.

It receives these paths from other routers using BGP. Each path comes with a set of labels, called attributes, that describe the path: how many networks it passes through, which organization owns it, whether it is a local or external path, and more. The router has a fixed checklist, like a post office rulebook, that tells it which attribute to look at first, then second, and so on.

It compares the paths attribute by attribute until only one path remains. That is the best path. For example, if two paths have the same first few attributes, the router checks the next attribute to break the tie.

The process continues until a winner is chosen. This ensures that internet traffic flows efficiently and according to the policies of network operators worldwide. Without BGP Best Path Selection, a router might send data on a slow, congested, or even incorrect route, causing delays or lost information.

Full Technical Definition

The BGP Best Path Selection algorithm is a deterministic, step-by-step process implemented in routers running the Border Gateway Protocol. BGP is a path vector protocol, meaning it exchanges reachability information and path attributes between autonomous systems. When a BGP router receives multiple routes to the same network prefix from different peers, it must select a single best route to install in the routing table and advertise to other BGP neighbors.

The algorithm compares routes based on a defined order of attributes, starting with the highest weight. The full list of comparison steps, as used in Cisco IOS, includes: highest Weight (locally configured, Cisco proprietary), highest Local Preference (local to the AS), prefer locally originated routes (via network or aggregate command), shortest AS_PATH length, lowest Origin type (IGP < EGP < incomplete), lowest Multi-Exit Discriminator (MED), prefer eBGP over iBGP, lowest IGP metric to the next-hop, and if all else equal, lowest Router ID. Each step eliminates all but one route, or if a tie remains, proceeds to the next step.

The process is converged and stable, meaning the same set of routes always produces the same best path. In real implementations, network engineers can influence the selection by modifying attributes like Weight, Local Preference, MED, or by using AS_PATH prepending. The algorithm is defined in RFC 4271 and is mandatory for all BGP implementations, though some vendor-specific extensions like Weight exist.

Understanding this process is critical for CCNP Enterprise certification candidates, as they must be able to predict and manipulate path selection in complex BGP topologies. The algorithm only applies to routes for the same prefix learned from different peers, not to routes for different networks. Once the best path is selected, the router installs it in the routing table and, if configured, advertises it to other BGP neighbors.

Real-Life Example

Imagine a large office building with a single main entrance and a security checkpoint. Employees need to get to their desks on different floors. However, there are multiple elevators and stairwells, each leading to the same floor but through different routes.

The building manager, much like a BGP router, has a strict protocol for deciding which elevator or stairwell each employee should use. The protocol checks several factors in order. First, it looks at the employee's badge type.

A VIP badge (highest weight) gets priority access to the express elevator. If no VIP badge exists, the manager checks the employee's department (local preference). Marketing department employees always take the north stairwell, while engineering takes the south stairwell.

If employees are from the same department, the manager looks at how many floors the elevator passes through (AS_PATH length). A direct elevator to the 10th floor is preferred over one that stops at every floor. If two elevators go directly, the manager checks which elevator was originally built for that floor (origin type).

A dedicated service elevator is better than a shared one. If still tied, the manager checks the elevator's maintenance record (MED), preferring the elevator with fewer recent repairs. If all factors are identical, the manager just picks the elevator closest to the entrance (lowest IGP metric).

Finally, as a tiebreaker, the manager picks the elevator with a lower serial number (lowest Router ID). This system ensures every employee uses the most appropriate route to their desk, balancing speed, policy, and efficiency. Just like BGP Best Path Selection, the manager's decision is predictable and consistent, following a fixed checklist every time.

Why This Term Matters

BGP Best Path Selection matters because the internet relies on millions of routes being chosen correctly every second. Without a standard decision process, routers could pick paths that cause congestion, increase latency, or break connectivity altogether. In real IT work, network engineers must ensure that traffic flows according to business needs.

For example, a company with two internet connections might want all customer traffic to use one link and all backup traffic to use another. The engineer can manipulate BGP attributes like Local Preference or Weight to make that happen. Similarly, content delivery networks use BGP to guide users to the closest server.

If the best path selection is misconfigured, users across the world might experience slow load times or be directed to a server on a different continent. In enterprise networks, BGP is used to connect to service providers, cloud providers, and partners. Choosing the best path is not just about speed; it is about reliability, cost, and policy.

For instance, a company might prefer a path that goes through a trusted partner AS rather than a public transit provider, even if the AS_PATH is longer. The best path selection algorithm allows this policy to be enforced automatically. Cybersecurity also plays a role.

BGP hijacking attacks rely on injecting false routes with manipulated attributes. Understanding how best path selection works helps engineers detect anomalous route changes and implement protections like RPKI and BGP Flowspec. For anyone managing a network that uses BGP, mastering this algorithm is essential for troubleshooting connectivity issues, optimizing performance, and maintaining control over traffic flows.

How It Appears in Exam Questions

Exam questions about BGP Best Path Selection come in several formats. Multiple choice questions often present a list of attributes and ask which one is checked first. For example: Which BGP attribute is considered first during the best path selection process?

The correct answer is Weight, which is a Cisco proprietary attribute. Another common type is scenario based: A router receives three routes to network 10.1.1.0/24 from three different peers.

The table shows the Weight, Local Preference, AS_PATH length, and MED for each route. Which route will the router choose? The candidate must apply the steps in order. Weight is checked first, so if one route has the highest Weight, that route wins regardless of other attributes.

If two routes have the same Weight, Local Preference breaks the tie. Configuration questions might ask: A network engineer wants to ensure that traffic from the AS uses a specific exit point. Which attribute should be configured on inbound routes?

The answer is Local Preference, because it is the second attribute checked and applies to all routes within the AS. Troubleshooting questions are also common. For instance: Users report that traffic from one branch to the data center is taking a suboptimal path.

The network has two BGP connections to two different ISPs. The engineer checks the BGP table and sees that the preferred route has a higher MED than an alternate route. Why is the route with higher MED still selected?

The candidate must realize that MED is only compared when all previous attributes are equal. Perhaps the preferred route has a higher Weight or Local Preference. Another question pattern involves eBGP vs iBGP.

Candidates must know that eBGP routes are preferred over iBGP routes, all else being equal. Questions may ask: A router receives a route via eBGP from one peer and via iBGP from another peer. All attributes are equal.

Which route is installed? The correct answer is the eBGP route, because the algorithm checks eBGP over iBGP at step eight. Finally, exam questions may include exhibits showing BGP table output from a router.

The candidate must interpret the output to identify the best path and explain why. Understanding these question patterns helps candidates prepare effectively.

Study encor

Test your understanding with exam-style practice questions.

Practise

Example Scenario

A medium sized company, GlobeLink, has two internet service providers: ISP Alpha and ISP Beta. Both ISPs provide full BGP tables to GlobeLink's router. The network administrator notices that traffic to a popular cloud service hosted at network 203.

0.113.0/24 is going through ISP Alpha, even though ISP Beta has a faster link. The administrator checks the BGP table on GlobeLink's router. For the prefix 203.0.113.0/24, there are two routes.

The route from ISP Alpha has a Weight of 0 and a Local Preference of 100, and an AS_PATH of 65000 12345 6789. The route from ISP Beta also has a Weight of 0 and a Local Preference of 100, but an AS_PATH of 65000 12345. Both routes have the same Weight, so the router checks Local Preference next.

Both have a Local Preference of 100, so still tied. Then the router compares AS_PATH length. The route from ISP Beta has a shorter AS_PATH (two ASNs) compared to ISP Alpha (three ASNs).

Therefore, the router selects the route from ISP Beta. However, the administrator expected traffic to go through ISP Alpha because of a business agreement. To fix this, the administrator can change the Weight on the route from ISP Alpha to a higher value, for example 200.

Since Weight is checked first, the route from ISP Alpha will now win, and traffic will flow through ISP Alpha as desired. This scenario shows how understanding the selection order allows the administrator to predict and influence routing decisions.

Common Mistakes

Assuming that the shortest AS_PATH is always the best path, regardless of other attributes.

AS_PATH is only the fourth attribute checked. Attributes like Weight, Local Preference, and locally originated routes are checked before AS_PATH. A route with a longer AS_PATH but higher Weight will still be chosen.

Always check attributes in the correct order: Weight first, then Local Preference, then locally originated, and only then AS_PATH.

Thinking that MED is compared before Local Preference or AS_PATH.

MED is the sixth attribute in the Cisco implementation, compared only after Local Preference, locally originated routes, and AS_PATH. MED is often misunderstood as a primary metric.

Remember the order: Weight, Local Preference, locally originated, AS_PATH, Origin, MED. MED only matters if all previous attributes are equal.

Believing that eBGP routes are always preferred over iBGP routes in all situations.

eBGP is preferred over iBGP only when all earlier attributes are equal. If an iBGP route has a higher Local Preference than an eBGP route, the iBGP route wins.

Treat the eBGP vs iBGP comparison as one step among many, not an absolute rule. It only comes into play when everything else is tied.

Confusing Weight and Local Preference, thinking they are interchangeable.

Weight is a Cisco proprietary attribute that is local to the router and is checked first. Local Preference is a standard attribute that is propagated throughout the AS and is checked second. They have different scopes and behaviors.

Weight applies only to the local router, while Local Preference affects the entire AS. Weight is checked before Local Preference.

Assuming that the best path selected by BGP is always the path with the lowest IGP metric to the next hop.

The IGP metric is the ninth attribute checked, coming after many others. It is only a tiebreaker. Most of the time, a path is selected before reaching this step.

The IGP metric is relevant only when all previous eight attributes are equal. In practice, this is rare. Do not jump to this step prematurely.

Exam Trap — Don't Get Fooled

An exam question shows two BGP routes with identical Weight, Local Preference, and AS_PATH length, but different Origin types: IGP and incomplete. A candidate might think that since all previous attributes are equal, the tiebreaker must be MED or Router ID, but the Origin type is actually checked before MED. Memorize the full attribute order: Weight, Local Preference, locally originated, AS_PATH, Origin, MED, eBGP vs iBGP, IGP metric, Router ID.

Practice applying the order with sample tables. The Origin attribute is IGP less than EGP less than incomplete, so a route with Origin IGP will beat a route with Origin incomplete, even if MED is lower on the incomplete route.

Commonly Confused With

BGP Best Path SelectionvsBGP AS_PATH Prepending

AS_PATH prepending is a technique used to influence best path selection by artificially lengthening the AS_PATH to make a route less preferred. Best path selection is the algorithm itself, while AS_PATH prepending is one tool that affects a specific attribute within that algorithm.

If you have two internet links and want traffic to prefer the first, you can prepend additional AS numbers to the second link's routes, making their AS_PATH longer so the algorithm rejects them. The algorithm is the judge; prepending is a way to bribe the judge.

BGP Best Path SelectionvsOSPF Metric Calculation

OSPF calculates the best path using a single metric called cost, based on link bandwidth. OSPF does not have multiple attributes or policy based selection. BGP Best Path Selection uses many attributes, each checked in order, allowing network engineers to apply complex policies.

In OSPF, the path with the lowest cumulative cost wins automatically. In BGP, you could make a route with a higher cost win by setting a higher Weight, which would override any cost consideration. OSPF is simpler; BGP is more flexible.

BGP Best Path SelectionvsBGP Route Reflector

A BGP route reflector is a router that reflects routes to iBGP peers to reduce the need for a full mesh. Route reflectors do not change the best path selection algorithm, but they can introduce path diversity and affect which routes are available for selection. The algorithm still runs on each router independently.

A route reflector receives the same route from two clients but might prefer one over the other based on attributes. The reflector then advertises only its best path to other clients. The algorithm still picks the best path; the reflector just controls route propagation.

BGP Best Path SelectionvsBGP Community

A BGP community is a tag attached to a route that can be used to trigger actions like changing Local Preference or MED. Communities influence the attributes that the best path selection algorithm uses, but they are not part of the selection algorithm itself. Think of communities as labels that cause attribute changes.

A service provider may attach a community value to a route that tells the customer router to set Local Preference to 150. The router then applies that Local Preference, and the algorithm will use that value during selection. The community is the instruction; the algorithm is the execution.

Step-by-Step Breakdown

1

Weight (Highest wins)

Weight is a Cisco proprietary attribute that is local to the router. It is checked first. If one route has a higher Weight than all others, it becomes the best path immediately. Weight is set locally and is not advertised to BGP peers. This allows a network engineer to override all other attributes for a specific router without affecting the rest of the AS.

2

Local Preference (Highest wins)

Local Preference is a standard BGP attribute used to influence path selection within an autonomous system. It is exchanged between iBGP peers but not eBGP peers. If two routes have the same Weight, the route with the highest Local Preference wins. This is commonly set on routes received from service providers to prefer one link over another for all routers in the AS.

3

Locally Originated Routes (Prefer local)

If the router itself originated the route via a network statement, aggregate address, or redistribution, that route is preferred over routes learned from BGP peers. This step ensures that locally injected routes are used first, which makes sense because the router is authoritative for its own networks.

4

Shortest AS_PATH

The AS_PATH attribute lists the autonomous systems that a route has traversed. A shorter path is considered better because it indicates fewer hops between ASes. If two routes have the same previous attributes, the route with the fewest AS numbers in its AS_PATH wins. This is a key metric for internet routing, as it often correlates with a more direct path.

5

Lowest Origin Type

The Origin attribute indicates how the route was learned. IGP (Internal Gateway Protocol) is preferred over EGP (Exterior Gateway Protocol), and both are preferred over Incomplete (typically from redistribution). If AS_PATH length is equal, the route with the most preferred origin wins. IGP routes are considered more trustworthy.

6

Lowest Multi-Exit Discriminator (MED)

MED is a metric that suggests to a neighboring AS which link to use when multiple links exist between the same two ASes. A lower MED is preferred. MED is only compared when the routes come from the same neighboring AS. This step helps in environments with multiple connections to the same provider.

7

Prefer eBGP over iBGP

If all preceding attributes are equal, eBGP learned routes are preferred over iBGP learned routes. eBGP routes are considered more direct because they come from outside the AS, while iBGP routes may have been learned through an internal route reflector with potential for suboptimal paths.

8

Lowest IGP Metric to Next Hop

This step compares the internal routing metric (e.g., OSPF cost, EIGRP metric) to the BGP next hop address. The route with the lowest IGP metric to reach its next hop is preferred. This encourages the router to use the next-hop that is closest in terms of interior gateway protocol distance.

9

Lowest Router ID (or BGP Identifier)

If all other attributes are equal, the route from the BGP speaker with the lowest Router ID is selected. The Router ID is usually the highest loopback IP address or a manually configured value. This is a final deterministic tiebreaker that ensures a unique best path is always chosen.

Practical Mini-Lesson

BGP Best Path Selection is not just a theoretical concept; it is a practical tool that network professionals use daily to control traffic flow. To apply it effectively, you need to understand how to manipulate attributes. Start with Weight if you want to influence only a single router.

For example, on a border router that connects to two ISPs, you can set a higher Weight on routes from the preferred ISP. This ensures that specific router uses that ISP, even if other routers in the AS have different preferences. For AS wide control, use Local Preference.

Set it on routes received from your primary ISP to a higher value, like 200, and on the backup ISP to 100. All routers in your AS will prefer the primary link, as Long as everything else is equal. To influence inbound traffic from external networks, you can use AS_PATH prepending or MED.

If you want traffic from a specific neighboring AS to enter your network through a particular link, set a lower MED on that link's routes. However, MED only works if the neighboring AS respects it. Another common practice is to use BGP communities to automatically set Local Preference or MED.

For instance, your ISP might offer a community that reduces the Local Preference of routes, making them less preferred for traffic leaving your network. This is a simple way to implement load sharing without manual configuration on every router. When troubleshooting, always check the BGP table first using show bgp ipv4 unicast.

Look at the attributes for each route and manually apply the algorithm step by step. This will reveal why a particular path was chosen. For example, if traffic is going over a slow backup link even though a fast link is available, check if the Weight or Local Preference is set incorrectly.

Also verify that the routes are not being filtered. A common issue is that the preferred route is not even in the BGP table due to prefix filtering or route map rejection. In such cases, even if attributes would make it best, the router cannot select it.

Finally, remember that the best path selection algorithm only applies to routes for the same prefix. If you have two different prefixes, the router selects a best path for each independently. This means you can have traffic to one destination using one link and traffic to another destination using a different link, which is perfectly normal.

Understanding this granularity helps in designing robust, policy driven networks.

Memory Tip

Remember the order with the acronym: We Love Oranges, Apples, Peaches, Mangoes, Every Day In Summer. We (Weight), Love (Local Preference), Oranges (Originated), Apples (AS_PATH), Peaches (Origin), Mangoes (MED), Every (eBGP/iBGP), Day (IGP metric), In (Router ID), Summer (final).

Covered in These Exams

Related Glossary Terms

Frequently Asked Questions

Does BGP always select the path with the lowest AS_PATH?

No, AS_PATH is only the fourth attribute. If a route has a higher Weight or Local Preference, it will win even if its AS_PATH is longer. AS_PATH only matters when all earlier attributes are equal.

Can I change the order of attributes in BGP best path selection?

No, the algorithm is fixed and follows a strict order. You cannot reorder the steps. However, you can influence the outcome by modifying the attribute values using route maps or other configuration tools.

What is the difference between Weight and Local Preference?

Weight is a Cisco proprietary attribute that is local to the router and checked first. Local Preference is a standard BGP attribute that is propagated throughout the AS and checked second. Weight overrides Local Preference.

How does MED differ from Local Preference?

MED is used to influence inbound traffic from a neighboring AS, while Local Preference influences outbound traffic within your AS. MED is compared after Origin, while Local Preference is compared much earlier in the algorithm.

Why does the router select an eBGP route over an iBGP route when all else is equal?

The eBGP route is preferred because it comes from a directly connected external AS, indicating a more direct path. iBGP routes may have been propagated through internal routers, potentially adding unnecessary hops or loops.

What happens if two routes are still tied after checking all attributes?

The algorithm uses the lowest Router ID as the final tiebreaker. This guarantees a deterministic result, so the same set of routes always produces the same best path.

Summary

BGP Best Path Selection is the fundamental mechanism that enables routers to choose the single best route among multiple BGP paths to the same network. The process follows a strict, step by step order of attributes, beginning with Weight and ending with Router ID. Network engineers can influence this selection by modifying attribute values, giving them powerful control over traffic flow.

This topic is a core component of the Cisco CCNP Enterprise certification, particularly the ENCOR exam, where candidates must understand both the theory and practical application. Common mistakes include misordering the attributes or assuming that one attribute always overrides others. The algorithm ensures deterministic, policy driven routing across the internet and enterprise networks.

For certification success, memorize the attribute order, practice with sample tables, and understand how each attribute can be manipulated. This knowledge is not just for exams; it is essential for real world network design, troubleshooting, and optimization. By mastering BGP Best Path Selection, you gain the ability to control how traffic enters and exits your network, ensuring performance, reliability, and alignment with business objectives.