Learn why BGP prefers eBGP routes over iBGP when all attributes are equal. This blog explains the concept with an easy topology, configuration, and clarification on the AD vs path selection confusion.
In the previous blogs, we explored several BGP path selection attributes like
Each of these attributes gives us more control over how BGP chooses the “best” path to reach a destination.
Now, let’s move to the next attribute in the BGP decision-making process:
eBGP is preferred over iBGP
Sounds simple? Let’s break it down step by step.
Understanding eBGP vs iBGP
- eBGP (External BGP): A BGP session formed between two routers in different Autonomous Systems (ASNs).
- iBGP (Internal BGP): A BGP session formed between two routers in the same Autonomous System (ASN).
When BGP has multiple paths to the same destination and all higher-priority attributes (like Weight, Local Preference, AS Path, Origin, MED) are the same, the router will always prefer the eBGP-learned route over the iBGP-learned one.
Why? Because eBGP paths are considered “closer to the actual source” compared to iBGP paths.
Network Topology Example
Let’s imagine a simple topology:

- R1 and R2 is an iBGP neighbor (same AS – 100).
- R3 is an eBGP neighbor (different AS – 300).
Configuration Snippet
conf t
interface g1/0
no shutdown
ip address 13.1.1.1 255.255.255.0
interface g2/0
no shutdown
ip address 12.1.1.1 255.255.255.0
router bgp 100
neighbor 13.1.1.3 remote-as 300
neighbor 12.1.1.2 remote-as 100
conf t
interface g1/0
no shutdown
ip address 12.1.1.2 255.255.255.0
interface g2/0
no shutdown
ip address 23.1.1.2 255.255.255.0
router bgp 100
neighbor 23.1.1.3 remote-as 300
neighbor 12.1.1.1 remote-as 100
conf t
interface g1/0
no shutdown
ip address 13.1.1.3 255.255.255.0
interface g2/0
no shutdown
ip address 23.1.1.3 255.255.255.0
interface loopback 0
ip address 3.3.3.3 255.255.255.255
router bgp 300
neighbor 13.1.1.1 remote-as 100
neighbor 23.1.1.2 remote-as 100
network 3.3.3.3 mask 255.255.255.255
Verification on R1 –
The BGP is showing UP with the both neighbor

Let’s check and verify the BGP table –


Oh, R1 selects the prefix 3.3.3.3 via router R3, which is its eBGP neighbor, why? Lets explore
Why Did R1 Choose eBGP?
- Weight is 0.
- Local preference is 100.
- Originate is the same because R3 advertised it.
- AS Path length is the same.
- Origin code (IGP).
- MED is the same.
Even though both eBGP and iBGP are advertising the same prefix with identical attributes, BGP’s decision-making rule says eBGP > iBGP.
This makes sense in real networks because:
- eBGP represents a direct path to an external network (closer to the real destination).
- iBGP is just a re-advertisement within the same AS (less preferred).
Important Clarification: eBGP vs iBGP and Administrative Distance (AD)
Many engineers get confused and assume that eBGP is preferred over iBGP because of the Administrative Distance (AD) values:
- eBGP AD = 20
- iBGP AD = 200
But this is not the reason for eBGP preference inside BGP.
Here’s the difference:
- AD (Administrative Distance): Used when the same prefix is learned from different routing protocols (e.g., OSPF vs eBGP vs iBGP).
- BGP Path Selection Rules: Used when multiple paths are learned within BGP itself.
So, when R1 receives the same prefix from both R2 (eBGP) and R3 (iBGP), the BGP decision process (not AD) makes it choose the eBGP path.
In short:
- AD decides across routing protocols.
- BGP best-path algorithm decides inside BGP.
Key Takeaways
- BGP always prefers eBGP over iBGP when all other attributes are equal.
- This behavior is built-in and cannot be changed unless you manipulate other attributes (like Weight, Local Preference, etc.).
- Remember this during troubleshooting: if you see both eBGP and iBGP paths to the same prefix, BGP will always select the eBGP one.
Conclusion
The rule “eBGP is preferred over iBGP” might look simple, but it’s extremely important in real-world BGP designs. It ensures that your router prefers the direct external route over an internal re-advertised one, keeping routing efficient and logical.