BGP Prefers the Path with the Lowest IGP Metric

BGP Path Selection – Understanding “BGP Prefers the Path with the Lowest IGP Metric”

So far in our BGP Best Path Selection series, we have explored several decision-making rules that BGP follows-

Weight

Local Preference

Locally Originated

AS Path

Origin Code

MED

BGP Prefer eBGP over iBGP

Now, it’s time to move to the next step in the selection process:

Although this attribute appears later in the selection order, it plays a crucial role when multiple routes have the same BGP attributes.

Before diving deeper, let’s refresh two key terms:

  • BGP (Border Gateway Protocol) – BGP acts like the international courier service of the Internet. It manages how data moves between different autonomous systems (AS) — think of these as different countries connected globally.
  • IGP (Interior Gateway Protocol) – IGP protocols such as OSPF, EIGRP, or IS-IS work within a single autonomous system. They’re like your local delivery network, ensuring data finds the fastest route inside your “country.”

Simple Analogy:
If BGP handles international deliveries, IGP handles the local routes inside each country.

An IGP metric is a numeric value that represents how “costly” or “difficult” it is to reach a particular destination inside a network.
Each IGP uses its own logic to calculate this cost:

  • OSPF – Based on interface bandwidth (lower cost = faster link)
  • EIGRP – Based on delay and bandwidth
  • RIP – Based purely on hop count

You can think of the IGP metric as travel time or toll cost — the lower the value, the quicker or cheaper it is to get there.


When a router learns multiple BGP routes to the same destination, and all other BGP attributes are identical, it still needs a way to break the tie.

At this stage, BGP looks inside the AS and asks:

“Which next-hop router is easier to reach according to my IGP?”

It checks the IGP metric to each BGP next-hop address and chooses the route with the lowest internal cost.

Analogy:
Imagine two international flights that land at different airports in your country, but both eventually reach the same city. If one airport is much closer to your home, you’ll pick that one — it’s cheaper and faster to get there locally.
That’s exactly how BGP makes its choice based on IGP metrics.


image

In this topology, OSPF is configured across all routers to provide internal connectivity. Routers R1 and R4 establish iBGP sessions through intermediate routers R2 and R3.
Next, we’ll perform the basic IP addressing, OSPF setup, and BGP configuration on all routers. Refer to the configurations below for step-by-step details.

Configuration –

conf t

router ospf 100

interface g1/0
no shutdown
ip address 12.1.1.1 255.255.255.0
ip ospf 100 area 0

interface g2/0
no shutdown
ip address 13.1.1.1 255.255.255.0
ip ospf 100 area 0

router bgp 100

neighbor 24.1.1.4 remote-as 100
neighbor 34.1.1.4 remote-as 100

conf t

router ospf 100

interface g1/0
no shutdown
ip address 12.1.1.2 255.255.255.0
ip ospf 100 area 0

interface g2/0
no shutdown
ip address 24.1.1.2 255.255.255.0
ip ospf 100 area 0

conf t

router ospf 100

interface g1/0
no shutdown
ip address 34.1.1.3 255.255.255.0
ip ospf 100 area 0

interface g2/0
no shutdown
ip address 13.1.1.3 255.255.255.0
ip ospf 100 area 0

conf t

router ospf 100

interface g1/0
no shutdown
ip address 34.1.1.4 255.255.255.0
ip ospf 100 area 0

interface g2/0
no shutdown
ip address 24.1.1.4 255.255.255.0
ip ospf 100 area 0

router bgp 100
neighbor 12.1.1.1 remote-as 100
neighbor 13.1.1.1 remote-as 100

After completing the basic configurations, let’s verify that the OSPF adjacencies and BGP sessions are established correctly on all routers.

image

image

Next, we will configure loopback interfaces on routers R1 and R4, advertise their IPs via BGP, and then verify how these prefixes propagate to neighboring routers, checking which path the traffic takes.

!!!! R1  
conf t
interface loopback 0
ip address 1.1.1.1 255.255.255.255  

router bgp 100
network 1.1.1.1 mask 255.255.255.255
!!!! R4  
conf t
interface loopback 0
ip address 4.4.4.4 255.255.255.255  

router bgp 400
network 4.4.4.4 mask 255.255.255.255

The configuration appears correct. Next, let’s verify how the prefixes advertised by R1 are reaching R4.

In the snapshot below, you can see that routers R1 and R4 are preferring the path via router R2. Additionally, the metric appears to be the same for both paths (through R2 and R3).

image

image

Now it’s our turn to influence traffic using the IGP metric. In this scenario, we’ll increase the metric on the path through R2 while keeping the metric on the path through R3 lower. This ensures that R1 and R4 select the path via R3 as the preferred route.

Next, let’s modify the OSPF cost values and verify the results.

image

image

Oh, notice that the best path has now changed from R2 to R3. Also, if you look at the metric, the cost is higher than the one learned through the R3 router.

  • Use BGP attributes like LOCAL_PREF, MED, AS-PATH for predictable traffic engineering whenever possible.
  • Reserve IGP metric manipulation for small, controlled environments.
  • Document all metric changes to avoid accidental wide-scale routing changes.
  • Test changes in a lab or maintenance window first.
  • BGP uses a step-by-step comparison of route attributes to select the best path.
  • When all BGP-specific attributes are identical, it looks at the IGP metric to the next-hop.
    The lower the IGP metric, the more preferred the route.
  • You can influence BGP path decisions by adjusting IGP costs – but do so carefully, as it also affects overall internal routing.
  • IGP is a network-wide routing protocol. Changing OSPF or IS-IS costs on a link affects all destinations that traverse that path, not just the BGP next-hop.
  • Example: Increasing the OSPF cost to R2 to make BGP prefer R3 may also cause some internal traffic (non-BGP destinations) to take alternate routes, which could lead to unintended congestion or suboptimal paths.

We’ve now understood how BGP prefers the path with the lowest IGP metric to reach the next-hop, continuing our journey through the BGP Best Path Selection process.
In the next part of this series, we’ll explore the next attribute in the selection order and see how BGP breaks further ties when IGP costs are equal.