The Question Every CCNA Asks
At some point in every network engineer's career, the question comes up: we already have OSPF and IS-IS, so why does BGP exist? Both protocols build routing tables. Both converge after a failure. So what does BGP do that an IGP can't?
The answer has two parts: scale and policy. Once you understand those two things, BGP starts making sense.
Scale: Why IGPs Fall Apart at Internet Size
OSPF works by flooding link-state advertisements to every router in an area. Every router builds a complete map of the topology, then runs SPF to find the shortest path to each destination. That's elegant and fast for a campus or data center. It does not work for the internet.
The public internet has over 900,000 prefixes. If OSPF had to flood all of that to every router, every device on the internet would need enough memory to hold a full topology database covering every link on the planet. The SPF calculation would take minutes, not milliseconds. The convergence storm after a single link failure would be catastrophic.
BGP solves this by being a path-vector protocol instead of a link-state protocol. Routers don't share topology. They share reachability: "I can reach this prefix, and the path goes through these ASes." Neighbors only send updates when something changes, and they only send what their neighbor needs to know. The control plane stays manageable even at internet scale.
Policy: Controlling Traffic the Way Businesses Actually Need
IGPs route to the nearest exit. The metric is cost, and the protocol picks the lowest-cost path. That's fine when all paths belong to you. It's a problem when you're a carrier with paying customers, peering agreements, and traffic engineering requirements.
BGP lets you express routing policy. You can say: prefer this upstream over that one. Only accept routes tagged with this community value. Never send customer routes to other customers. Prepend your AS to make a path look longer and attract less traffic. None of that is possible with OSPF or IS-IS.
That's the core reason BGP exists. It's not faster than OSPF. It converges more slowly. But it gives operators control that link-state protocols simply don't have.
Autonomous Systems and the iBGP/eBGP Distinction
An Autonomous System (AS) is a collection of IP prefixes under a single administrative domain with a consistent routing policy. Your ISP is an AS. A large enterprise might be an AS. Each AS gets a unique number, the ASN, assigned by IANA and regional registries.
BGP runs in two modes depending on where the session is:
eBGP (external BGP): between routers in different ASes. This is what ISPs use to exchange routes with each other and with their customers.
iBGP (internal BGP): between routers inside the same AS. Used to distribute BGP routes learned from outside throughout your own network.
The key difference is behavior. eBGP peers are almost always directly connected, and the TTL on the TCP session defaults to 1. iBGP peers can be anywhere in the AS, usually peering via loopback addresses with multihop enabled. iBGP also does not modify AS_PATH when passing routes between internal peers, which is how the AS presents a consistent view to the outside world.
The TCP Session on Port 179
BGP runs over TCP, port 179. That's unusual for a routing protocol. OSPF runs directly over IP. IS-IS runs directly over layer 2. EIGRP runs over IP with its own reliable transport.
BGP's designers made a deliberate choice: use TCP and get reliable, ordered delivery for free. BGP sessions carry large routing tables and need to handle updates without losing a prefix here or there. TCP handles retransmission, flow control, and sequencing. BGP just builds on top of that.
The session lifecycle is: Idle, Connect, Active, OpenSent, OpenConfirm, Established. Most troubleshooting starts at the Established state failing. Common reasons: ACL blocking TCP 179, wrong neighbor IP, TTL expiring before the packet arrives, MD5 auth mismatch.
BGP Attributes: What Gets Attached to Every Route
Every BGP route carries a set of attributes. Some are mandatory, some optional. These attributes are how policy gets expressed.
AS_PATH
The list of ASes a route has passed through, ordered from most recent to origin. When a router receives a route with its own AS in the AS_PATH, it drops it. That's how BGP prevents routing loops. AS_PATH is also used for policy: prefer the route with the shorter AS_PATH, or filter routes that pass through certain ASes.
NEXT_HOP
The IP address the receiving router should use to reach the prefix. For eBGP, this gets updated at each AS boundary. For iBGP, it stays as the eBGP peering address, which is why internal routers need a route to that address (usually via IGP).
LOCAL_PREF
Used only within an AS. Higher is preferred. This is the primary tool for controlling which exit point your AS uses when multiple paths exist to the same destination. Set LOCAL_PREF on inbound eBGP routes to steer outbound traffic.
MED (Multi-Exit Discriminator)
Sent to neighboring ASes to influence which of your entry points they use. Lower MED is preferred. It's a suggestion, not a requirement. The neighboring AS is free to ignore it.
COMMUNITY
A tag you attach to routes for policy purposes. Can be used to trigger actions at other routers: set LOCAL_PREF based on community, suppress a route, or signal a peer to do something specific. Well-known communities include NO_EXPORT (don't send outside the AS) and NO_ADVERTISE (don't send to any BGP peer).
BGP Best-Path Selection
When a router has multiple paths to the same prefix, it runs the best-path algorithm. The steps in order:
Highest weight (Cisco-only, local to the router)
Highest LOCAL_PREF
Locally originated (network statement or redistribute)
Shortest AS_PATH
Lowest origin code (IGP less than EGP less than incomplete)
Lowest MED (only compared if same neighboring AS)
eBGP over iBGP
Lowest IGP metric to NEXT_HOP
Oldest eBGP route (stability preference)
Lowest router-id of the advertising peer
In practice, most path selection decisions get made at step 2 (LOCAL_PREF) or step 4 (AS_PATH length). The rest of the list handles tiebreakers.
Route Reflection: Solving the iBGP Full-Mesh Problem
iBGP has a split-horizon rule: a route learned from one iBGP peer cannot be advertised to another iBGP peer. The reason is loop prevention. The side effect is that every iBGP router must peer directly with every other iBGP router. In a network with 100 routers, that's 4,950 sessions. It doesn't scale.
Route reflectors solve this. A route reflector (RR) can re-advertise iBGP routes to its clients. Clients peer only with the RR, not with each other. The RR adds the ORIGINATOR_ID and CLUSTER_LIST attributes to prevent loops.
Most production networks use at least two route reflectors per cluster for redundancy. The RR doesn't need to be in the forwarding path. It just needs iBGP sessions to all clients and enough memory to hold the full RIB.
BGP in the Data Center
BGP is now the standard underlay protocol for spine-leaf data center fabrics. RFC 7938 describes the design. The reasons are practical: eBGP between spines and leaves gives you fast convergence, no need for a full-mesh of iBGP sessions, and clean AS boundaries that make troubleshooting easier.
Each leaf gets its own private ASN. Each spine gets its own ASN. Leaves peer with spines via eBGP. The AS_PATH length naturally prevents asymmetric routing. It's simple and it works at scale. That's why Arista, Cisco, and Juniper all recommend this model for large fabrics.
Basic Config: eBGP Peering on Cisco IOS
! On Router A (AS 65001), peering with Router B (AS 65002)
router bgp 65001 bgp router-id 10.0.0.1 neighbor 192.168.1.2 remote-as 65002 neighbor 192.168.1.2 description peer-to-router-b ! address-family ipv4 unicast neighbor 192.168.1.2 activate network 10.1.0.0 mask 255.255.255.0 exit-address-family! Verification
show bgp summary
show bgp ipv4 unicast
show bgp ipv4 unicast neighbors 192.168.1.2 received-routes
show bgp ipv4 unicast regexp ^65002$The show bgp summary output shows session state, prefixes received, and uptime. MsgRcvd and MsgSent incrementing is a healthy sign. A session stuck in Active means TCP isn't completing. A session stuck in OpenSent usually means a parameter mismatch.
The Practical Takeaway
BGP is not about being fast. It's about being controllable. Every design decision in the protocol, from TCP transport to path-vector mechanics to the attribute system, exists to give network operators the ability to express policy at scale.
If you're studying for CCNP or beyond, the best way to build intuition for BGP is to lab it. Set up three routers, give them different ASNs, advertise some routes, and start manipulating LOCAL_PREF and AS_PATH. The behavior makes much more sense once you've watched the best-path change in real time.
Watch the video
Prefer video? The full BGP deep dive series is on YouTube.
Next in this series
BGP as a Path Vector: AS Path, Loop Prevention, and Why It Matters →
Comments (0)
Please sign in to comment.