π‘ 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
| Type | Description | Preferred When |
|---|
| eBGP | Between DIFFERENT ASes | Connecting to ISP, cloud, external networks |
| iBGP | Inside the SAME AS | Sharing 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)
| Tool | Purpose |
|---|
| Prefix-List | Allow/block specific IP prefixes |
| Route-Map | Modify BGP attributes (LP, MED, tags, etc) |
| Distribute-List | Basic filtering (rarely used with BGP) |
| Communities | Tag routes for easier policy control |
βοΈ Controlling Traffic β BGP Attributes
| Attribute | Used For | Preferred When |
|---|
| Local Preference | Outbound traffic (higher = preferred) | Choose best exit from your AS |
| AS Path | Inbound traffic (shorter = preferred) | Influence how others come to you |
| MED | Suggest best inbound route (lower = better) | You have multiple links to same neighbour |
| Weight (Cisco) | Local to the router only | Tie-breaker, not shared with others |
π¦ Use Cases β Whatβs Preferred?
| Use Case | Preferred Setup |
|---|
| Advertise public prefix | eBGP with network |
| Share loopbacks internally | iBGP with network |
| Connect to 2 ISPs | Dual eBGP + AS path prepending |
| Share eBGP routes internally | iBGP with route reflector or full-mesh |
| Prefer one ISP for outbound | Set higher Local Preference |
| De-prioritize inbound route | AS 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?
| Protocol | Preferred For |
|---|
| OSPF / EIGRP / IS-IS (IGP) | Internal routing (fast convergence) |
| BGP | External routing, policy control, WAN scale |
1
2
| Use IGP for underlay (reachability),
Use BGP for overlay (control, flexibility)
|
β
Quick Recap Table
| Goal | Preferred Method |
|---|
| Connect to ISP | eBGP |
| Advertise internal services | iBGP + network statement |
| Internal reachability | IGP (OSPF, EIGRP, etc.) |
| Multi-router internal setup | iBGP with Route Reflector |
| Stable peering | Loopbacks + update-source |
| Load balancing out | Local Preference |
| Load balancing in | AS Path Prepending or MED |
| Avoid iBGP full mesh | Route Reflector |
| Avoid route leaks | Prefix-lists + route-maps |
1
2
3
| π₯ Final Tip:
Always filter what you advertise.
The Internet doesn't like surprises.
|
π Connect With Me
