Post

BGP - The Real-World Guide (Not Boring)

BGP - The Real-World Guide (Not Boring)

πŸ“‘ BGP - The Real-World Guide (Not Boring)

1
2
3
BGP (Border Gateway Protocol) is how routers across 
different networks (Autonomous Systems - AS) talk 
to each other to exchange route information.

🌐 BGP Types - eBGP vs iBGP

TypeDescriptionPreferred When
eBGPBetween DIFFERENT ASesConnecting to ISP, cloud, external networks
iBGPInside the SAME ASSharing BGP routes within your own routers or data centers

🀝 BGP Neighbours (Peers)

BGP needs neighbours to share routing info. You can use physical IPs or loopbacks.

βœ… Use loopbacks + β€œupdate-source” for stability βœ… Use β€œebgp-multihop” if not directly connected

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
## πŸ” eBGP - External BGP

βœ… Preferred when:
- Connecting to another AS (e.g. ISP, cloud provider)
- Advertising your public IPs
- Receiving external internet routes

🧠 Notes:
- Default TTL = 1 (direct connect)
- Use `ebgp-multihop` if not directly connected
- You CAN use `network` command

---

## πŸ”„ iBGP - Internal BGP

βœ… Preferred when:
- Sharing routes between routers in the same AS
- Data center or enterprise BGP backbone
- Redistributing eBGP-learned routes internally

🧠 Notes:
- iBGP needs full-mesh or Route Reflectors
- Next-hop is NOT changed by default β†’ IGP must reach it
- You CAN use `network` command here too

---

## πŸ”ƒ iBGP Full-Mesh vs Route Reflector

| Design          | Preferred When                                      |
|------------------|----------------------------------------------------|
| Full-Mesh        | Small networks (3–5 routers)                       |
| Route Reflector  | Larger networks (5+ routers), ISPs, DC cores       |

🧠 RR allows non-full mesh by letting one router reflect routes to others.

---

## 🌍 Loopback vs Physical Interface

| Interface Used   | Preferred When                                          |
|------------------|--------------------------------------------------------|
| Loopback         | You want stable BGP peering over multiple paths        |
| Physical         | Simpler setups with direct cables                      |

Use: neighbor X.X.X.X update-source loopback0

πŸ”’ BGP network Command

βœ… You can use network in both eBGP and iBGP

🧠 How it works:

  • Tells BGP: β€œIf this route exists in my routing table, advertise it”
  • Must match exact prefix
  • Good for manual control

βœ… Preferred When:

  • You want to control what routes are advertised
  • Advertising static or IGP-known prefixes

πŸ”„ Redistribute into BGP

βœ… You CAN redistribute static or IGP routes into BGP
⚠️ Use with caution β€” not preferred without filtering

❌ Not Preferred When:

  • You want stability and clean route control
  • You don’t have route-maps or filters

βœ… Preferred When:

  • You have many dynamic routes to advertise
  • You’re okay managing filters (prefix-lists, route-maps)

🧰 Route Filtering Tools

ToolPurpose
Prefix-ListAllow/block specific IP prefixes
Route-MapModify BGP attributes (LP, MED, tags, etc)
Distribute-ListBasic filtering (rarely used with BGP)
CommunitiesTag routes for easier policy control

βš–οΈ Controlling Traffic – BGP Attributes

AttributeUsed ForPreferred When
Local PreferenceOutbound traffic (higher = preferred)Choose best exit from your AS
AS PathInbound traffic (shorter = preferred)Influence how others come to you
MEDSuggest best inbound route (lower = better)You have multiple links to same neighbour
Weight (Cisco)Local to the router onlyTie-breaker, not shared with others

πŸ“¦ Use Cases – What’s Preferred?

Use CasePreferred Setup
Advertise public prefixeBGP with network
Share loopbacks internallyiBGP with network
Connect to 2 ISPsDual eBGP + AS path prepending
Share eBGP routes internallyiBGP with route reflector or full-mesh
Prefer one ISP for outboundSet higher Local Preference
De-prioritize inbound routeAS Path Prepending
Remote peering (not directly connected)Use loopback + ebgp-multihop

🚨 What’s NOT Preferred

❌ iBGP without full mesh or route reflector
❌ Redistribute BGP into IGP (can cause loops)
❌ Advertising too many routes without filters
❌ Not ensuring next-hop reachability in iBGP


🧯 BGP vs IGP – When to Use Each?

ProtocolPreferred For
OSPF / EIGRP / IS-IS (IGP)Internal routing (fast convergence)
BGPExternal routing, policy control, WAN scale
1
2
Use IGP for underlay (reachability), 
Use BGP for overlay (control, flexibility)

βœ… Quick Recap Table

GoalPreferred Method
Connect to ISPeBGP
Advertise internal servicesiBGP + network statement
Internal reachabilityIGP (OSPF, EIGRP, etc.)
Multi-router internal setupiBGP with Route Reflector
Stable peeringLoopbacks + update-source
Load balancing outLocal Preference
Load balancing inAS Path Prepending or MED
Avoid iBGP full meshRoute Reflector
Avoid route leaksPrefix-lists + route-maps

1
2
3
πŸ”₯ Final Tip: 
Always filter what you advertise. 
The Internet doesn't like surprises.

πŸ™Œ Connect With Me

GitHub LinkedIn YouTube Gmail

This post is licensed under CC BY 4.0 by the author.