What is BGP (Border Gateway Protocol)?
Learn what BGP is, how AS-paths prevent loops, eBGP vs iBGP, and why the internet runs on policy-based routing — interview Q&A.
Expected Interview Answer
BGP is the path-vector routing protocol that connects autonomous systems across the internet, exchanging reachability information as a full list of the AS numbers a route has traversed so each router can pick paths and apply policy rather than just minimize hop count.
Unlike interior protocols such as OSPF that optimize for shortest path within one organization, BGP’s job is to let independently administered networks, called autonomous systems (AS), advertise which IP prefixes they can reach and through which sequence of other autonomous systems. Every BGP route carries an AS-path attribute, and a router rejects any advertisement that already contains its own AS number, which is what prevents routing loops across the internet. BGP is policy-driven rather than purely metric-driven: an ISP might prefer a customer route over a peer route regardless of path length, because business relationships and cost, not just distance, decide the best path. eBGP sessions run between routers in different autonomous systems, typically on directly connected links, while iBGP sessions run between routers inside the same AS to distribute externally learned routes internally without changing the AS-path.
- Scales the entire internet by exchanging reachability, not full topology
- AS-path prevents inter-domain routing loops
- Policy-based path selection reflects real business relationships
- Separates external (eBGP) from internal (iBGP) route propagation
AI Mentor Explanation
BGP is like the agreements between rival cricket boards about which international fixtures they will honor and route tours through, rather than every board picking opponents purely by shortest travel distance. Each board announces which countries it can arrange a tour to and lists every board the itinerary already passed through, so a tour never loops back through the same board twice. A board might route a tour through a partner federation even if a shorter path exists, simply because of an existing bilateral agreement. This mirrors how BGP advertises AS-paths and applies policy over pure distance.
Step-by-Step Explanation
Step 1
Peering session
Two routers in different (eBGP) or the same (iBGP) autonomous systems establish a TCP-based BGP session.
Step 2
Route advertisement
Each router advertises reachable prefixes along with an AS-path listing every AS the route has traversed.
Step 3
Loop prevention
A router rejects any advertisement whose AS-path already contains its own AS number.
Step 4
Policy-based selection
The router applies local policy (local preference, AS-path length, MED) to pick the best path, not just the shortest one.
What Interviewer Expects
- Correctly identifies BGP as a path-vector, inter-domain protocol
- Explains the AS-path attribute and its loop-prevention role
- Distinguishes eBGP (between AS) from iBGP (within AS)
- Understands BGP is policy-driven, not purely shortest-path
Common Mistakes
- Confusing BGP with an interior gateway protocol like OSPF
- Assuming BGP always picks the shortest AS-path regardless of policy
- Not knowing iBGP exists to propagate routes within an AS
- Forgetting that BGP runs over TCP port 179
Best Answer (HR Friendly)
“BGP is the protocol that lets the internet’s independent networks, like ISPs and large companies, tell each other which addresses they can reach and through whom. It is less about finding the mathematically shortest path and more about following business agreements between networks, which is why it is often called the protocol that actually holds the internet together.”
Code Example
vtysh
# Show established BGP sessions with peer AS numbers
show ip bgp summary
# Show the BGP table, including AS-path per route
show ip bgp
# Show only routes matching a specific prefix
show ip bgp 203.0.113.0/24Follow-up Questions
- What is the difference between eBGP and iBGP?
- How does the AS-path attribute prevent routing loops?
- What is a BGP route reflector and why is it needed?
- How does local preference influence BGP path selection?
MCQ Practice
1. What type of routing protocol is BGP?
BGP is a path-vector protocol that advertises the full AS-path a route has traversed.
2. What prevents BGP routing loops between autonomous systems?
A router discards any advertisement whose AS-path already includes its own AS number.
3. Which BGP session type runs between routers within the same autonomous system?
iBGP distributes externally learned routes among routers inside the same AS.
Flash Cards
What is BGP? — The path-vector protocol that exchanges reachability between autonomous systems across the internet.
What is an AS-path? — The list of autonomous systems a route has traversed, used for loop prevention and path selection.
eBGP vs iBGP? — eBGP runs between different autonomous systems; iBGP runs between routers within the same AS.
Is BGP shortest-path based? — No — it is policy-driven, weighing business relationships alongside path attributes.