BGP Fundamentals
π°οΈ BGP Fundamentals β Interview & Beginner Friendly Guide
β What is BGP?
BGP stands for Border Gateway Protocol β itβs the standard exterior gateway protocol (EGP) used to exchange routing information between autonomous systems (AS) on the Internet.
π§ Key BGP Concepts:
- Layer: Works at Layer 7 (Application Layer) of the OSI model.
- Transport Protocol: Uses TCP (Transmission Control Protocol).
- Port Number: TCP port 179.
- Protocol Type: Path Vector Protocol (unlike Distance Vector or Link State).
- Slow Protocol: Because of reliability and policy-based nature.
π Types of BGP
| Type | Full Form | Scope | Admin Distance |
|---|---|---|---|
| iBGP | Internal BGP | Inside same AS | 200 |
| eBGP | External BGP | Between different AS | 20 |
π Note: No auto-discovery or multicast is used in BGP. All neighbors must be configured manually.
π BGP Basics
- AS (Autonomous System): A group of routers under a single administrative domain.
- BGP tracks AS-path to determine loop-free routing.
- BGP can form neighborship with:
- Directly connected routers
- Remotely connected routers (static routes used to reach them)
π οΈ BGP Configuration Syntax
On Cisco routers (example):
1
2
3
router bgp 100
neighbor <IP> remote-as 500
network <LAN prefixes>
π BGP Message Types
| Message Type | Purpose |
|---|---|
| OPEN | Start session, exchange BGP version, AS number, BGP ID, Hold Timer |
| KEEPALIVE | Heartbeat, sent every 60s (β of hold timer 180s) |
| UPDATE | Send routing info (NLRI β Network Layer Reachability Info) |
| NOTIFICATION | Send errors, alerts |
π§± TCP/IP Stack Relevance in BGP
| Layer | Name | Function | BGP Relevance | Port Number Role |
|---|---|---|---|---|
| Layer 7 | Application | Handles application-specific logic (BGP, HTTP, FTP, etc.) | BGP runs here as a routing application | Requests or binds to port 179 (BGP) |
| Layer 4 | Transport | End-to-end communication, reliable delivery using TCP | BGP uses TCP for reliable neighbor communication | Encapsulates source & destination ports |
| Layer 3 | Internet | Logical addressing and routing (IP layer) | Uses IP addresses to reach BGP peers | No direct involvement with ports |
| Layer 2 | Data Link | Physical addressing and frame delivery (MAC, Ethernet) | Responsible for hop-to-hop delivery on same link | No direct involvement with ports |
| Layer 1 | Physical | Transmits raw bits over physical medium (cables, fiber, etc.) | Underlying physical connectivity between routers | No involvement |
π BGP Finite State Machine (FSM)
BGP has several states before a session is fully established:
πΉ TCP Phase States
- Idle
- Initial state when
router bgp <asn>is configured. - On
neighbor <IP> remote-as <asn>, BGP starts TCP connection (port 179). - Initializes BGP resources and listens for incoming connections.
- Initial state when
- Connect
- Starts TCP 3-way handshake (SYN, SYN-ACK, ACK).
- If fails, starts ConnectRetry timer (120s).
- On failure β goes to Active. On success β OpenSent.
- Active
- Tries new TCP connection.
- If fails β back to Connect and retries (timer resets).
- If successful β move to OpenSent.
β οΈ Frequent transition between Connect/Active indicates TCP issues (ACLs, port 179 blocked, IP reachability).
πΉ BGP Phase States
- OpenSent
- Sends OPEN message (BGP version, ASN, router ID, Hold Timer, optional capabilities).
- If mismatch/error β sends NOTIFICATION β back to Idle.
- If matched β move to OpenConfirm.
- OpenConfirm
- Waits for KEEPALIVE message from peer.
- If received β go to Established.
- If not received β reset to Idle.
- Established
- BGP session fully up.
- Exchange UPDATE messages (NLRI, path attributes).
- Sends KEEPALIVE every 60s (1/3 of Hold Timer 180s).
- If no UPDATE/KEEPALIVE in hold time β reset to Idle.
π§ Two-Phase Process
- Phase 1: TCP Phase β Establish transport connection
- β Idle β Connect β Active
- Phase 2: BGP Phase β Exchange BGP messages
- β OpenSent β OpenConfirm β Established
π Quick FSM Flow Summary
1
2
3
4
5
6
7
8
9
Idle
βββΆ Connect (start TCP handshake)
β βββΆ success β OpenSent
β βββΆ fail β Active
β βββΆ success β OpenSent
β βββΆ fail β Connect (retry)
OpenSent
βββΆ OpenConfirm (if OPEN accepted)
βββΆ Established (if KEEPALIVE received)
β In Established, routes are exchanged via UPDATEs, and session health is maintained via KEEPALIVEs. If any error or timer expires β back to Idle.
π BGP State Flow Summary
1
Idle β Connect β Active β OpenSent β OpenConfirm β Established
Each transition depends on TCP success/failure and BGP message exchange.
π§© Inter-AS BGP Example (From Diagrams)
- R1 (AS 100) β R2 (AS 200): eBGP
- R2 β R3: Static route (to reach remote peer)
- R3 β R4 (AS 200): iBGP
- R4 advertises internal routes to ISP 1/2 using BGP.
π Redistribution and Routing
- Common redistribution from:
- OSPF β Admin Distance: 110
- EIGRP β Admin Distance: 90
- Static β Admin Distance: 1
- BGP routes can be redistributed to IGPs (OSPF, EIGRP), and vice versa.
π§ Additional Key Terms
- NLRI (Network Layer Reachability Info): The actual IP prefixes being advertised.
- AS Path: Tracks all AS numbers a route has passed through. Used for loop prevention.
- Hold Timer: Typically set to 180 seconds.
- Keepalive Timer: Sent every 60 seconds.
π Interview Tips
- Know all BGP FSM states and transitions.
- Be able to explain TCP 3-way handshake in the context of BGP.
- Understand difference between iBGP vs eBGP.
- Remember BGP does not use multicast or auto-discovery.
- Know default Administrative Distances:
- eBGP = 20
- iBGP = 200
- Be able to draw or describe AS-level topologies.
β Conclusion
BGP is the backbone of internet routing. While itβs complex, understanding the message types, state machine, and configuration basics can set a strong foundation for deeper learning and acing interviews.