BGP Fundamentals for CCNA
AI-Generated Content
BGP Fundamentals for CCNA
Border Gateway Protocol (BGP) is the postal service of the global internet, responsible for delivering data between continents, countries, and companies. As the only standardized Exterior Gateway Protocol (EGP) in widespread use, BGP’s primary job is to exchange routing information between different, independently managed networks. For your CCNA studies, you don’t need to configure complex BGP policies, but you must understand its foundational role, core operational logic, and how it makes routing decisions that keep the internet connected. Mastering these concepts is crucial for grasping how enterprise networks interact with the wider world.
What is BGP and the Autonomous System?
At its heart, Border Gateway Protocol (BGP) is a path-vector routing protocol. Unlike interior gateway protocols like OSPF or EIGRP that find the shortest path within a single network, BGP is designed to select the best path across multiple, independently controlled networks. It does this by sharing not just destination and next-hop information, but the entire path of networks used to reach that destination.
The fundamental unit in BGP is the Autonomous System (AS). An AS is a collection of routers under a single technical administration, sharing a common routing policy. An ISP, a large university, or a global corporation would each have their own AS number. This number, assigned by a regional internet registry, is how BGP uniquely identifies an organization on the internet. BGP’s primary function is to facilitate routing between these autonomous systems, making it the protocol of inter-AS routing.
eBGP vs. iBGP: Two Types of Peering
BGP forms a connection, called a peer or neighbor relationship, between two BGP-speaking routers. This relationship is categorized based on whether the peers are in the same or different Autonomous Systems.
External BGP (eBGP) is used between routers in different Autonomous Systems. This is the classic use case—for example, your company’s edge router peering with your ISP’s router. By default, eBGP peers are assumed to be directly connected, and BGP attributes are modified when routes are advertised over an eBGP session to prevent routing loops.
Internal BGP (iBGP) is used between routers within the same Autonomous System. Why would you need this? Because of a critical BGP rule: BGP routers do not advertise routes learned from one iBGP peer to another iBGP peer. This "split-horizon" rule prevents loops inside the AS but requires a full mesh of iBGP connections or the use of a route reflector. iBGP is used to ensure all BGP routers in your AS have a consistent view of external routes learned via eBGP. A key operational difference is that the Next-Hop attribute is not changed by default between iBGP peers, often requiring an extra configuration step.
Key BGP Attributes: The Decision Factors
BGP uses path attributes attached to each network prefix to describe the route’s characteristics and to enable path selection. Think of these as tags on a suitcase that describe its journey. For the CCNA, you should focus on these fundamental attributes:
- AS_Path: This is the most recognizable attribute. It is a list of AS numbers that the route advertisement has traversed. For example, a route showing
64500 65100 65200passed through those three ASes. BGP uses this list to detect and prevent routing loops—a router will reject a route if its own AS number is already in the ASPath. A shorter ASPath is generally preferred. - Next Hop: This specifies the IP address of the next router to which packets should be forwarded to reach the destination network. For eBGP, this is typically the IP address of the external peer. For iBGP, this value is not changed from the eBGP-learned value, which often points to an IP address outside the local AS, requiring an IGP (like OSPF) to have a route to that "next-hop" address.
- Local Preference (Local_Pref): This is a powerful attribute used to influence outbound traffic flow within an AS. Local Preference is set internally and is not advertised to eBGP peers. A higher Local Preference value is always preferred. If you have two connections to two different ISPs, you can assign a higher Local Preference to the route from your preferred ISP, making it the best path for all routers inside your AS.
The BGP Best Path Selection Algorithm
When a BGP router receives multiple paths to the same destination prefix, it must choose the single best path to install in its routing table and advertise to its peers. It does this by running a strict, sequential decision process. For CCNA, you need to know the order and key tie-breakers:
- Highest Weight (Cisco proprietary, local to router): If set, the path with the highest weight is chosen.
- Highest Local Preference: The path with the highest Local_Pref wins.
- Locally Originated: A path locally sourced via network or aggregate command is preferred.
- Shortest AS_Path: The path with the fewest AS numbers in the AS_Path is preferred.
- Lowest Origin Type: Prefer IGP origin (
i) over EGP (e) over Incomplete (?). - Lowest Multi-Exit Discriminator (MED): A hint sent to neighboring ASes about your preferred entrance point. Lower MED is preferred.
- eBGP over iBGP Paths: An eBGP-learned path is preferred over an iBGP-learned path.
- Lowest IGP Metric to Next-Hop: The path whose next-hop address has the lowest cost according to the Interior Gateway Protocol (like OSPF) is chosen.
The process continues through more tie-breakers, but these first eight are the core for foundational understanding. The key is that BGP is not about speed; it’s a policy-based protocol designed for control and stability.
Basic BGP Configuration and Verification
At the CCNA level, you should be able to recognize and understand a basic eBGP configuration. The core steps involve activating BGP with your AS number, specifying neighbors, and advertising networks.
Router(config)# router bgp 64500 ! Enable BGP with local AS number 64500
Router(config-router)# neighbor 203.0.113.2 remote-as 65100 ! Specify eBGP peer IP and its AS
Router(config-router)# network 192.168.1.0 mask 255.255.255.0 ! Advertise a network into BGPCritical verification commands include:
-
show ip bgp summary: Displays a list of BGP neighbors and their state. Look for the state column to read "Established," which means the peer session is active. -
show ip bgp: Displays the entire BGP table, showing all learned paths, their attributes, and the best path marked with a>symbol. -
show ip route bgp: Shows only the BGP-learned routes that have been installed in the main IP routing table.
Common Pitfalls
- Misunderstanding the Next-Hop Attribute in iBGP: A router learning a route via iBGP will, by default, keep the original next-hop IP from the eBGP peer. If the local router has no route to that next-hop IP in its routing table (via an IGP), the BGP route will be considered invalid and not used. The solution is to either ensure the next-hop IP is reachable via the IGP or use the
next-hop-selfcommand on the iBGP neighbor configuration. - Assuming BGP Advertises All Routes Automatically: Unlike some IGPs, BGP does not automatically advertise networks. You must explicitly announce networks using the
networkcommand or through redistribution. Furthermore, the network must be exactly match an entry in the router's IP routing table (or be more specific) for BGP to advertise it. - Forgetting the iBGP Full-Mesh Requirement: Because of the iBGP split-horizon rule, a route learned from one iBGP peer will not be advertised to another iBGP peer. In a simple topology with three iBGP routers (A, B, and C), if Router A learns a route via eBGP, it will tell Router B (iBGP). Router B will not tell Router C about that route, leaving Router C unaware. The solutions are to create a full mesh of iBGP connections between all routers or to implement a Route Reflector, which is a designated router allowed to reflect iBGP-learned routes to other iBGP clients.
- Confusing BGP Administrative Distance: In Cisco routers, eBGP routes have an Administrative Distance (AD) of 20, iBGP routes have an AD of 200, and locally sourced BGP routes have an AD of 200. It’s easy to forget that an iBGP route (AD 200) will always lose to a similar route learned from OSPF (AD 110) or EIGRP (AD 90) during the router's best path selection process, even if the BGP path is "better" according to BGP's own algorithm.
Summary
- BGP is the path-vector EGP that routes between Autonomous Systems (AS), making it the fundamental protocol of the global internet.
- eBGP is used between different ASes (e.g., you and your ISP), while iBGP is used within the same AS to synchronize external routing information, following a strict split-horizon rule.
- BGP uses attributes like AS_Path (for loop prevention and path length), Next-Hop (the forwarding IP), and Local Preference (for internal outbound traffic steering) to describe and select routes.
- The BGP Best Path Selection Algorithm is a deterministic, multi-step process that prioritizes policy controls (LocalPref, ASPath length) over simple metrics.
- Basic configuration involves defining the local AS, specifying neighbors with their remote AS, and manually advertising networks with the
networkcommand. Always verify the neighbor state is Established.