BGP Protocol: Complete Guide
Build a clear mental model of autonomous systems and peering, then practice session establishment, route advertisement, best-path selection, policy control, traffic engineering, and evidence-led troubleshooting.
BGP Overview: Autonomous Systems and Best Path: Quick Summary
BGP is a classless interdomain routing protocol designed for scalability, routing policy, and control. It establishes manually configured neighbor relationships over TCP, exchanges prefixes with path attributes, selects one best path by default, and advertises eligible routes according to configured policy.
BGP primarily connects autonomous systems on the internet, but iBGP is also used inside service-provider, enterprise, data-center, and cloud networks to distribute externally learned routes. Multiprotocol BGP supports IPv4, IPv6, VPN routes, EVPN routes, and other address families.
Protocol Type
Path-vector Exterior Gateway Protocol.
Transport
Unicast TCP port 179. BGP does not use multicast neighbor discovery.
Administrative Distance
Cisco default is 20 for eBGP and 200 for iBGP.
Recommended BGP Study Order
- Begin with the BGP overview to understand why BGP uses TCP port 179, autonomous systems, neighbors, and separate address families.
- Review BGP key concepts before configuration so terms like eBGP, iBGP, AS_PATH, NEXT_HOP, and communities are clear.
- Move to BGP configuration and build a small neighbor relationship in a lab or simulator.
- Use BGP path attributes to learn how routers choose a best path when multiple routes exist.
- Practice routing policies with prefix lists, route maps, AS path filters, local preference, MED, and communities.
- Finish with BGP troubleshooting so you can verify sessions, advertised routes, received prefixes, and best-path decisions.
BGP Protocol Architecture
BGP routers are commonly called BGP speakers. Unlike OSPF or EIGRP, BGP does not automatically discover neighbors. Each peer is normally configured with a neighbor address and a remote autonomous system number.
The routers first establish IP reachability and complete the TCP three-way handshake. They then exchange BGP OPEN messages with the BGP version, autonomous system number, hold time, router ID, and supported capabilities. After the parameters are accepted, peers exchange KEEPALIVE messages and enter the Established state.
BGP does not select a route simply because it has the highest bandwidth or fewest router hops. It verifies that the path is valid, checks NEXT_HOP reachability, applies inbound policy, compares path attributes, selects a best path, and applies outbound policy before advertising a route to another peer.
Peering Types and Address Families
External BGP, or eBGP, connects peers in different autonomous systems. Internal BGP, or iBGP, exchanges BGP routes between routers in the same autonomous system. Small iBGP designs may use a full mesh, while larger networks commonly use route reflectors or confederations.
BGP neighbor establishment and route exchange are separate functions. A TCP session can be Established while routes are still missing because the neighbor has not been activated under the correct address family or because address-family policy is blocking the prefix.
Important BGP Path Attributes
- Weight: Cisco-specific and local to one router. A higher Weight is preferred.
- LOCAL_PREF: Shared inside the local AS to choose an outbound exit. A higher LOCAL_PREF is preferred.
- AS_PATH: Lists autonomous systems traversed by the route. A shorter AS_PATH is generally preferred after higher-priority attributes.
- NEXT_HOP: Identifies the next-hop address. A route cannot become usable when the next hop is unreachable.
- MED: Suggests a preferred entry point into an AS. A lower MED is generally preferred when comparable.
- Communities: Tag routes so consistent routing policy can be applied to groups of prefixes.
BGP Best Path Logic
The complete decision process varies by platform and configuration, but Cisco BGP commonly evaluates path validity, NEXT_HOP reachability, highest Weight, highest LOCAL_PREF, locally originated paths, shortest AS_PATH, lowest ORIGIN code, lowest comparable MED, eBGP over iBGP, and the lowest internal cost to the BGP next hop.
The selected BGP path may not be the physically shortest path. A longer path can be intentionally preferred because local routing policy assigns it a higher Weight or LOCAL_PREF.
Messages, Timers and Session States
BGP uses OPEN, UPDATE, KEEPALIVE, NOTIFICATION, and ROUTE-REFRESH messages. The healthy state is Established. Idle, Connect, Active, OpenSent, and OpenConfirm show where the peering process is currently stuck.
Common Cisco defaults are a 60-second keepalive timer and a 180-second hold timer. Receipt of an UPDATE or KEEPALIVE resets the hold timer.
BGP Design and Troubleshooting Notes
When a BGP session fails, confirm the remote AS, neighbor reachability, update source, TCP port 179 reachability, eBGP multihop requirements, and ACL behavior. Loopback-based peers require underlying IGP or static-route reachability.
When the session is Established but routes are missing, check address-family activation, exact prefix origination, route policy, AS_PATH filtering, NEXT_HOP reachability, and best-path eligibility.
Useful verification commands include show ip bgp summary, show ip bgp, show ip bgp <prefix>, show ip bgp neighbors, and show ip route bgp.
What a Useful BGP Lab Should Prove
A good BGP lab should prove neighbor establishment, prefix advertisement, next-hop reachability, route filtering, and path selection. After basic reachability works, add policy by changing local preference, prepending AS_PATH, filtering a prefix, and tagging a route with a community.
BGP Overview: Autonomous Systems and Best Path: Related Tools and Tests
- AS Number Calculator converts ASPLAIN, ASDOT, and hexadecimal ASN formats used in BGP documentation.
- IP Location Finder can identify the ASN, ISP, and organization associated with a public IP address.
- Routing Practice Test helps reinforce BGP path selection along with OSPF, EIGRP, and RIP topics.
- OSPF Labs, EIGRP Labs, and RIP Labs are useful comparisons when learning how policy-based routing differs from IGP behavior.