Border Gateway Protocol (BGP) Routing Overview

Border Gateway Protocol (BGP) is defined in RFC 1654 as an Exterior Gateway Protocol (EGP) standard path vector routing protocol. BGP was initially developed to enable IPv4 interconnectivity on public networks, like the Internet, and dedicated private networks.

BGP is the only protocol used to exchange networks on the Internet, which now has over 780,000 IPv4 routes and is growing. BGP does not advertise incremental updates or refresh network advertisements due to the huge size of the BGP tables. Therefore, a stable network is preferred when using BGP since a link flap might result in route computation for thousands of routes.

 

Autonomous System (AS)

AS is a collection of routers controlled by a single organization that uses one or more IGP routing protocols and common metrics to route packets among themselves. If an AS uses multiple IGPs or metrics, the AS must be consistent with external ASs in the routing policy. BGP routes can be used within an AS, so using an IGP would be unnecessary.

An Autonomous System Number (ASN) is required to connect to the Internet and exchange routing information between ASs. The Internet Assigned Numbers Authority (IANA) is in charge of allocating all public ASNs. ASNs originally had a 16-bit range, with 65,535 ASNs, which was exhausted. RFC 4893 expanded the ASN field to accommodate a 32-bit range, allowing for 4,294,967,295 ASNs.

The following private ASN blocks can be used by any organization provided that they will never be exchanged publicly on the Internet:

  • Private 16-bit ASN Range: 64,512–65,535
  • Private 32-bit ASN Range: 4,200,000,000–4,294,967,294

 

Path Attributes (PAs)

BGP makes use of path attributes (PAs) that are associated with each network path. The PAs enable granularity and control over BGP routing policies. According to RFC 4271, the BGP prefix PAs are categorized as follows:

  1. Well-Known Attributes – required to be recognized by all BGP implementations.
  • Well-Known Mandatory – must be accompanied by every prefix advertisement.
  • Well-Known Discretionary – may or may not be accompanied by a prefix advertisement.
  1. Optional Attributes – not required to be recognized by all BGP implementations.
  • Optional Transitive – stays with the route advertisement across Autonomous Systems.
  • Optional Non-Transitive – can’t be shared across Autonomous Systems.

 

The Network Layer Reachability Information (NLRI) in BGP is a routing update that includes the network prefix, prefix length, and any BGP PAs for a particular route.

 

Loop Prevention

AS_Path is a well-known mandatory PA used by BGP to prevent loops. It contains a complete list of all ASNs traversed by the prefix advertisement from its source AS. When a BGP router receives a prefix advertisement with its AS specified in the AS_Path, it will discard the prefix since it considers the prefix to create a loop.

For example, the image below shows four Autonomous Systems advertising the 192.168.1.0/24 prefix. AS 10 advertises the prefix to AS 20. AS 20 advertises the prefix to AS 30, then AS 30 to AS 40. AS 40 advertises the prefix back to the source AS, AS 10, with an AS_Path of AS 40-30-20-10. AS 10 sees itself in the AS_Path and discards the prefix.

BGP Routing

 

AFI and SAFI

BGP was originally designed to route IPv4 prefixes between organizations. RFC 2858 introduced Multi-Protocol BGP (MP-BGP) functionality by including an Address Family Identifier (AFI) extension. A network protocol, like IPv4 or IPv6, is associated with an address family. Subsequent Address Family Identifier (SAFI), such as unicast or multicast, provides extra granularity.

MP-BGP uses MP_REACH_NLRI and MP_UNREACH_NLRI path attributes for the separation. These PAs are included inside the BGP update messages and are used to transmit network reachability information for various address families.

Each address family has a separate database and configuration for each protocol (address + sub-address family), which allows different routing policies in different address families even if the routers share the same BGP session. BGP includes an AFI and SAFI on the route advertisements to distinguish AFI and SAFI databases.

 

BGP Inter-Router Communication

IP addresses are used to identify BGP neighbors. BGP communicates with other routers using TCP port 179. Most current BGP implementations use the do-not-fragment (DF) bit to avoid fragmentation and depend on path MTU discovery.

BGP utilizes TCP that can traverse network boundaries which is multi-hop capable. BGP can establish neighbor adjacencies that are directly connected, and it can also establish adjacencies that are multiple hops away.

The established adjacency between two BGP routers is called a BGP session. The router must use an underlying route installed in the Routing Information Base (RIB) to create a TCP session with the remote endpoint during a multi-hop session.

In the image below, Router1 establishes a direct BGP session with Router2. Router2 also establishes a BGP session with Router4. Router1 and Router2 use a directly connected route to locate each other. Router2 uses a static route to reach the 10.30.1.0/24 network, and Router4 uses a static route to reach the 10.20.1.0/24 network. Router3 is unaware that Router2 and Router4 have established a BGP session even though the packets flow through Router3.

BGP Neighbor Adjacency

The ARP table is used by BGP neighbors on the same network to find the IP addresses of their BGP peers. Multi-hop BGP sessions use the routing table information to locate the peer’s IP address. The topological path information required to initiate a BGP TCP session is typically provided by a static route or an IGP between internal BGP neighbors.

A default route is not enough to establish a multi-hop BGP session. BGP enables exchanging routes with peers that are multiple hops away. BGP routers can exchange prefixes without being on the data plane or path, but every router in the data path must be aware of every route passing through them.


Download our Free CCNA Study Guide PDF for complete notes on all the CCNA 200-301 exam topics in one book.

We recommend the Cisco CCNA Gold Bootcamp as your main CCNA training course. It’s the highest rated Cisco course online with an average rating of 4.8 from over 30,000 public reviews and is the gold standard in CCNA training: