BGP (Border Gateway Protocol) is the routing protocol that exchanges reachability information between autonomous systems, the independently managed networks that make up the internet. Where OSPF and EIGRP find paths inside one network, BGP decides which neighboring network to hand traffic to, and it does so by policy rather than by raw speed. This guide covers the concepts, the vocabulary, the best-path process, a first lab configuration and the troubleshooting points beginners hit first.
TL;DR
- BGP is an exterior gateway protocol: it routes between autonomous systems (ASes). OSPF and EIGRP are interior protocols that run inside one AS.
- BGP runs over TCP port 179. eBGP peers sit in different ASes. iBGP peers sit in the same AS.
- BGP is a path-vector protocol. Each route carries attributes, such as AS_PATH, that drive loop prevention and best-path choice.
- A session needs a router ID, a local AS number, a reachable neighbor and an explicitly configured address family.
- Practice by building small labs and breaking them on purpose. Reading alone does not make the states and attributes stick.
Table of Contents
- What BGP does and why it exists
- Autonomous systems, peers, eBGP and iBGP
- BGP compared with OSPF and EIGRP
- OSPF and EIGRP in a nutshell for CCNA study
- Path attributes you need to know
- How BGP chooses the best path
- Configure your first BGP session
- Troubleshooting a BGP session
- Why BGP security matters
- Perspective: why we teach routing by breaking it
- Build a practice routine
- Frequently asked questions
- Sources
What BGP does and why it exists
Every network on the internet needs a way to tell its neighbors which IP prefixes it can reach. BGP is the protocol that carries those announcements. RFC 4271 defines a BGP route as a set of destination prefixes (carried in NLRI, Network Layer Reachability Information) paired with path attributes that describe the path to those destinations.
The design goal was scale and control. The authors of the early BGP specifications and Juniper’s Day One routing book describe BGP as built to construct a scalable graph of autonomous systems while letting each operator enforce its own administrative, transit and security policies. That is why a provider can prefer one upstream over another for business reasons, even when the other path looks shorter.
BGP is a path-vector protocol. IEEE describes path-vector advertisements as carrying the sequence of ASes along the path. That sequence allows loop detection and policy-based selection, instead of simply picking the numerically shortest path.
Two more properties are worth knowing early:
- BGP does not re-send everything constantly. After the initial exchange of the full routing table, routers send only incremental updates, as documented in RFC 1774.
- BGP does not discover neighbors. You configure each peer by hand, because the peers are administrative relationships, not just adjacent cables.
Autonomous systems, peers, eBGP and iBGP
An autonomous system is a set of routers under a single technical administration. Each AS is identified by an AS number (ASN). Per Juniper’s BGP overview, BGP uses TCP port 179, eBGP exchanges routing information between different ASes, and iBGP exchanges it within one AS.
Think of a BGP session as a long-lived TCP connection between two configured routers. Because it rides on TCP, the two peers must already have IP reachability to each other before the session can come up. BGP does not build that reachability. A static route, a connected link or an IGP does.
eBGP versus iBGP
| Feature | eBGP | iBGP |
|---|---|---|
| Peers are in | Different ASes | The same AS |
| Typical peer location | Directly connected edge routers | Anywhere inside the AS, often loopbacks |
| Main job | Exchange routes with other networks | Carry external routes across your own network |
| AS_PATH on advertisement | Local ASN is prepended | Not changed |
A common beginner trap: iBGP does not pass a route learned from one iBGP peer on to another iBGP peer. That rule prevents loops inside an AS, since AS_PATH does not change inside it. Larger networks solve it with a full mesh of iBGP sessions, route reflectors or confederations. For CCNA-level study, know the rule and the reason first.
Why peer with loopbacks
When two routers have more than one path between them, Cisco’s guidance on loopback peering explains the benefit: a single physical interface failure will not bring down the BGP session, because the loopback stays reachable over the other path. It is the usual choice for iBGP.
BGP compared with OSPF and EIGRP
Cisco’s BGP introduction classifies BGP as an exterior gateway protocol for routing between autonomous systems, with support for policy-based decisions. OSPF and EIGRP are interior gateway protocols used within one autonomous system.
| Protocol | Type | Scope | Decides mainly by |
|---|---|---|---|
| OSPF | Link-state IGP | Inside one AS | Cost, calculated from the link-state database |
| EIGRP | Advanced distance-vector IGP | Inside one AS | Composite metric, by default bandwidth and delay |
| BGP | Path-vector EGP | Between ASes | Attributes and policy |
In practice they work together. An enterprise runs OSPF or EIGRP internally so every router can reach every internal prefix. It runs BGP at the edge to exchange routes with one or more internet providers. BGP then relies on the IGP to resolve next hops inside the network.
OSPF and EIGRP in a nutshell for CCNA study
BGP questions on the CCNA usually appear next to OSPF and EIGRP questions, so it helps to hold the interior protocols clearly in mind.
OSPF routers form neighbor adjacencies, flood link-state advertisements and each build the same map of the area. Every router then runs the shortest path first algorithm on that map. Know these terms: neighbor states, area 0 as the backbone, the designated router on multi-access segments, router ID, and cost. Typical exam tasks are reading show ip ospf neighbor output and finding why two routers will not become adjacent. Common causes are mismatched hello and dead timers, mismatched area IDs, mismatched subnet masks or an authentication mismatch.
EIGRP routers share routes with neighbors and choose paths using the DUAL algorithm. Know these terms: successor, feasible successor, feasible distance, reported distance, and the composite metric. Typical tasks are reading the topology table and understanding why a backup route is or is not a feasible successor.
The contrast with BGP is useful. OSPF and EIGRP discover neighbors automatically and optimize for a metric. BGP needs configured neighbors and optimizes for policy.

Path attributes you need to know
BGP attributes are the data attached to each route. Juniper classifies them as well-known mandatory, well-known discretionary, optional transitive or optional non-transitive. ORIGIN, AS_PATH and NEXT_HOP are well-known mandatory. MED is optional non-transitive. COMMUNITY is optional transitive.
- AS_PATH: the list of ASes the route has crossed. It is also the loop-prevention tool: if a router receives an update containing its own AS number, it drops the route.
- NEXT_HOP: the IP address to forward traffic to. If the router cannot resolve it, the path is unusable.
- ORIGIN: how the route was first injected into BGP.
- LOCAL_PREF: a value shared inside your AS to choose the preferred exit. Higher wins.
- MED: a hint sent to a neighboring AS about which of your entry points you prefer. Lower wins.
- COMMUNITY: a tag that lets operators attach policy to groups of routes.
- Weight: a Cisco-specific value that is local to the router and not advertised to peers.
How BGP chooses the best path
When a router learns the same prefix from several peers, it must pick one. Cisco documents the process as starting by rejecting unusable paths, including paths whose next hop cannot be resolved. It then compares attributes in order. In Cisco IOS XR the order is:
- Highest weight
- Highest local preference
- Locally originated routes
- Shortest AS_PATH
- Lowest ORIGIN
- Lowest MED, among paths from the same neighboring AS
- Later steps: eBGP over iBGP, lowest IGP metric to the next hop, and final tie-breakers
The exact list and the position of some steps differ by vendor and software version, so check the documentation for the platform you use. For exams, memorize the order for the vendor the exam covers. A simple mnemonic helps, but practicing with real outputs helps more.
A worked example. Your router learns 203.0.113.0/24 from two providers. Provider A’s path has an AS_PATH of three ASes, and provider B’s has two. With default settings and equal weight and local preference, the router prefers B for its shorter AS_PATH. If you set local preference to 200 on routes from A, the router prefers A, because local preference is checked before AS_PATH length. One value changed the outcome. That is policy at work.
Configure your first BGP session
Cisco’s NX-OS configuration guide lists the requirements for peering: enable BGP, configure a valid router ID and AS number, make sure the peer is reachable, and explicitly configure an address family under the neighbor.
Here is a minimal eBGP lab in Cisco IOS style. R1 is in AS 65001 and R2 is in AS 65002. They share the link 10.0.12.0/30.
- Configure the link addresses and confirm reachability with
ping. - Start BGP on R1 and name the neighbor:
R1(config)# router bgp 65001
R1(config-router)# bgp router-id 1.1.1.1
R1(config-router)# neighbor 10.0.12.2 remote-as 65002
R1(config-router)# address-family ipv4 unicast
R1(config-router-af)# neighbor 10.0.12.2 activate
R1(config-router-af)# network 192.168.1.0 mask 255.255.255.0
- Mirror the configuration on R2 with its own ASN, router ID, neighbor address and prefix.
- Verify the session and routes:
R1# show ip bgp summary
R1# show ip bgp
R1# show ip route bgp
The network command only advertises a prefix that already exists in the routing table with a matching mask. If R1 has no 192.168.1.0/24 route, BGP will not originate it. That is a classic first-lab mistake.
Next, extend the lab. Add a third router in AS 65001 and build an iBGP session with loopback peering using update-source. Then observe that the iBGP route does not reach it without next-hop-self on the edge router, because the eBGP next hop is outside the AS.
Troubleshooting a BGP session
Start with show ip bgp summary. The state column or prefix count tells you where to look.
| What you see | What it usually means | What to check |
|---|---|---|
| Idle | The router is not trying, or cannot start a connection | Neighbor statement, route to the peer, ACLs blocking TCP 179 |
| Active | The router is trying to open the TCP connection and failing | Reachability, source address, peer configuration on the other side |
| OpenSent or OpenConfirm | Open messages are exchanged but the session is not complete | AS number mismatch, router ID conflict, authentication |
| Established | The session is up | Whether prefixes arrive and are installed |
A short checklist when routes are missing:
- Can each peer ping the other from the source address it uses for the session?
- Does each side have the other’s ASN and IP address exactly right?
- Is the address family activated for the neighbor?
- Is the next hop reachable? Per Cisco’s process, a path with an unresolvable next hop is rejected before comparison starts.
- Does the prefix exist in the local routing table before a
networkstatement? - Did AS_PATH loop prevention drop the route because it already contains your ASN?
Work from the bottom up: IP reachability, TCP, session state, then routes and policy. Most beginner problems are in the first two layers.
Why BGP security matters
BGP was designed when operators trusted each other. According to the NTIA, BGP announcements do not authenticate the destination or the route. The NTIA notes that ARIN offers RPKI with ROA and ROV to validate announcements against signed route origin data. The practical lesson for beginners: a router will believe what a peer announces unless you filter or validate it. Prefix filters, maximum-prefix limits and RPKI-based origin validation are the standard defenses you will meet in later study.
Perspective: why we teach routing by breaking it
Routing protocols are easy to read about and hard to understand until you watch one fail. A BGP neighbor stuck in Active teaches more than a page of definitions, because you have to trace the cause through reachability, TCP and configuration.
That is how we built our platform. We give you free, unlimited, bite-sized lessons so each concept, from AS_PATH to the OSPF neighbor states, arrives in one short sitting. Then we give you realistic labs with automatic grading, so you find out right away whether your configuration works.
We also think review should follow your mistakes, not a fixed calendar. Our learning path uses spaced repetition and learns from your errors, so if you keep missing best-path ordering, that topic comes back sooner. Interior protocols and BGP reinforce each other, and a plan that adapts to your results helps you cover both before exam day.
Subnetica
Build a practice routine
BGP basics are small in number but need repetition. A routine that works:
- Learn one concept per session: AS numbers, then eBGP, then iBGP, then attributes.
- Build the two-router eBGP lab from this article from memory.
- Change one attribute, predict the best path, then verify with
show ip bgp. - Break the session on purpose (wrong ASN, missing address family, no route to the peer) and fix it using the troubleshooting table.
- Review OSPF and EIGRP the same way, with timer mismatches and feasible successor checks.
- Finish with timed practice questions that mix all three protocols.
Our free lessons, quizzes and labs on Subnetica cover this progression for CCNA and CompTIA Network+, and the adaptive path schedules reviews of the topics you miss. When you are ready to test yourself under exam conditions, the practice exams for CCNA and Network+ are the paid option, with unlimited attempts.

Frequently asked questions
Is BGP an interior or exterior protocol?
BGP is an exterior gateway protocol. It exchanges routes between autonomous systems. The same protocol also runs inside an AS as iBGP, to carry external routes across your own routers, but its design purpose is routing between networks.
Which port does BGP use?
BGP uses TCP port 179. One peer opens the connection to port 179 on the other. If a firewall or ACL blocks that port, the neighbor will sit in Idle or Active.
How is BGP different from OSPF and EIGRP?
OSPF and EIGRP are interior protocols that discover neighbors and choose routes by metric inside one AS. BGP connects separate ASes, needs manually configured neighbors and chooses routes by attributes and policy. Most networks run an IGP internally and BGP at the edge.
What is the first thing to check when a BGP neighbor will not come up?
Check IP reachability between the exact addresses used for the session, then confirm both sides have the right neighbor address and remote AS. Then verify nothing blocks TCP 179. Most failed sessions trace back to one of these three.
Do I need to know BGP for the CCNA?
Exam topics change between versions, so check the current Cisco exam blueprint. Whatever the blueprint says, understanding what BGP is, how eBGP differs from iBGP and how it relates to OSPF and EIGRP gives you a stronger routing foundation.
Sources
- RFC 4271: A Border Gateway Protocol 4 (BGP-4)
- Day One: Routing the Internet Protocol (Juniper Networks)
- Routing protocols (IEEE Technology Navigator)
- RFC 1774: BGP-4 Protocol Analysis
- BGP Overview (Junos OS)
- Configure iBGP and eBGP with or without a loopback address (Cisco)
- Border Gateway Protocol: introduction to BGP (Cisco)
- BGP path attributes and best path selection criteria (Juniper)
- How BGP path selection works (Cisco IOS XR)
- Configuring BGP (Cisco Nexus 9000 NX-OS)
- Border Gateway Protocol (NTIA)
Made with BabyLoveGrowth to reach people on Google and AI search

