Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

BGP

ASN

16-bit ASN - 65,535 32-bit ASN - 4,294,967,295

Private Numbers

  • 64,512 – 65,534
  • 4,200,000,000 – 4,294,967,294

BGP Path Attributes

RFC 4271 - BGP-4

  • Well-known mandatory
  • Well-known discretionary
  • Optional transitive
  • Optional nontransitive
Path AttributeCategory
OriginMandatory
AS_PATHMandatory
NEXT_HOPMandatory
LOCAL_PREFDiscretionary
ATOMIC_AGGREGATEDiscretionary
AGGREGATOROptional Transitive
COMMUNITYOptional Transitive
MULTI_EXIT_DISCOptional Non-Transitive
ORIGINATOR_IDOptional Non-Transitive
CLUSTER_LISTOptional Non-Transitive

BGP Uses TCP

  • Port 179
  • BGP is sensitive to IP fragmentation

Session Types

  • iBGP Administrative distance of 200
  • eBGP Administrative distance of 20

eBGP

  • TTL is set to 1.
  • Next-hop is set to what the BGP source connection IP is.
  • Check if the current AS_PATH has our AS.
  • Prepend AS into AS_PATH

BGP Packet Types

TypeNameFunctional Overview
1OPENinitial bringup
2UPDATERoutes and route updates
3NOTIFICATIONIndicates an error condition to a BGP neighbor
4KEEPALIVEMakes sure everything is OK

Theory

  • BGP works on the premise that if a router sees its own AS path, it must be a loop.
  • The default timer is 60 seconds with 180 seconds for hold time. This means worst-case is 3 minutes to fail-over.
  • BGP aggregate-address only works if there is a subnet inside the aggregate range in BGP.

Working With BGP

  • Only consider traffic in one direction at a time
  • Accepting a route will affect outgoing traffic
  • Advertising a route will affect incoming traffic
  • Filter out everything except the routes needed
  • BGP DOES NOT LOAD BALANCE

On Cisco IOS bgp soft-reconfig-backup tells the router “if you must, save a entire table” otherwise rely on RFC2918, which are dynamic updates.

Soft reconfig is ancient, pre-RFC.

Soft Reconfig via Route Refresh (trusting the other device)

clear ip bgp <neighbor_ip> soft in1

BGP Best Path Selection

- Higher Weigth                                       
- Higher Local Preference                            
- Locally Originated                                 (Network or Aggregate Command)
- Shortest AS-PATH
- Lowest Origin Type                                 (IGP > EGP > Incomplete)
- Lowest MED                                         (Neighbor ASes must be the same)
- eBGP > Confederated eBGP > iBGP
- Lowest IGP metric to next hop
- Is Multipath enabled?
  - Prefer external path which is oldest
  - Prefer path from router with lower ID
  - Prefer path with shorter cluster length
  - Prefer path from lowest neighbor address

Cisco - Select BGP Best Path Algorithm

WEIGHT

  • Cisco specific & this router only
  • Routes learned are 0
  • Locally generated routes are 32768

LOCAL_PREF

  • Controls traffic Outgoing traffic.
  • Only shared between iBGP peers, used to determine the exit. Higher is better.

AS Path

These read left to right like a book. This prefix was most recently from AS 7018.

7018 701 15 i
            ^ this means IGP, and AS 15 has an IGP route for it like OSPF or EIGRP

Next Hop

  1. eBGP, routers in different AS, destination outside AS. The Next hop will be the advertising router.
  2. iBGP, routers in same AS, destination inside AS. The Next hop will be the advertising router.
  3. iBGP, routers in same AS, destination outside AS. The Next hop is the external peer who advertised the address.

… When the third option happens …

  • Advertise into the IGP the external links to the BGP peers.
  • Tell the AS border router to change the next hop to its own IP address. (next-hop-self)

Origin

IGP > EGP > Incomplete

  • IGP means it came from an IGP. This is the highest preference.
  • Incomplete means its likely a redistributed route

MULTI_EXIT_DISC

  • Controls incoming traffic.
  • Lower is better

ATOMIC_AGGREGATE

BGP can aggregate smaller prefixes into larger ones even if a smaller prefix comes from a different AS.

A router in AS 105 gets these prefixes from its peers.

192.168.0.0/24 (123 204)
192.168.1.0/24 (123 205)

If the administrator chooses, they can aggregate this, but lose path information.

192.168.0.0/23 (105) ATOMIC_AGGREGATE. 

Downstream peers can not remove this tag

AGGREGATOR

AS and Router ID of the BGP router that did the atomic aggregation.

COMMUNITY

Usually used to tag routes from a specific customer.

TagPurpose
INTERNETDefault community.
NO_EXPORTDo not share with other ASes
NO_ADVERTISEDo not share with other routers
LOCAL_AS????

ORIGINATOR_ID

For route reflectors The origaning router puts its Router_ID here. If it sees this, it knows a loop as occured.

BGP By Default Will Summarize

Use no auto-summary.

Using redistribute under BGP will make the resulting route show up with an orign code of incomplete.

Sending A Default Route

neighbor A.B.C.D default-originate

To get iBGP routers to update the next-hop to be themselves when advertising to other iBGP routers use

neighbor A.B.C.D next-hop-self

This makes it so other iBGP routers don’t need reachability information for the physical link to the next AS.

BGP Neighbor States

Idle

Connect

Open Sent

Open Confirm

Active

Established

Fixing Next-Hop Issues

Just because the route shows up in show ip bgp doesn’t mean it will install. BGP needs to be able to reach the next-hop.

  1. Add the transit routes the IGP.
  2. Use next-hop self in BGP.
  3. Use a route-map to set the next hops.

References

RFC 4271: A Border Gateway Protocol 4 (BGP-4) | RFC Editor

The Network Times: Border Gateway Protocol – Finite State Machine (BGP-FSM)

BGP Troubleshooting Diagram

V. Jain and B. Edgeworth, Troubleshooting BGP: A Practical Guide to Understanding and Troubleshooting BGP, 1st ed. Indianapolis, IN: Cisco Press, 2016, ISBN 978-1-58714-464-6.

B. Edgeworth, R. Garza Rios, J. Gooley, and D. Hucaby, CCNP and CCIE Enterprise Core ENCOR 350-401 Official Cert Guide, 2nd ed. Indianapolis, IN: Cisco Press, 2023.

I. van Beijnum, Internet Routing with BGP, Kindle ed., Nov. 12, 2022, 269 pp.

Last Modified • Sunday, June 14, 2026. 9:31 pm UTC+00:00 • Commit: e0033bb

  1. https://www.cisco.com/c/en/us/td/docs/ios-xml/ios/iproute_bgp/configuration/xe-16/irg-xe-16-book/bgp-4-soft-configuration.html