Introduction to Border Gateway Protocol (BGP)
Cisco Border Gateway Protocol (BGP) is a complex topic that often overwhelms those just getting into the network arena. It also can be a confusing topic to cover, especially because it differs from many of the well-known routing protocols being used on most internal networks. The purpose of this article is to give a brief overview of BGP, where it is typically deployed, and how it can be helpful to any large-scale networking deployment.
Basic BGP Concepts
Unlike commonly known routing protocols like RIP, EIGRP, and OSPF, BGP is different fundamentally in how and where it operates. RIP, EIGRP, and OSPF are each considered Internal Gateway Protocols (IGP) — in other words, these protocols are intended to be used on the inside of a network and not necessarily between routing domains.
BGP, on the other hand, is an External Gateway Protocol (EGP), which was designed with the intention of connecting multiple large scale networks. Because of this assumption, BGP is exceptionally well suited for dealing with large-scale networks and a very large routing table while still being able to operate efficiently. The biggest example of a BGP deployment is the Internet, which is exclusively routed using BGP between all core connection points as well as between many of the smaller access points. BGP is also different from other routing protocols because it runs on top of TCP (port 179); this means that BGP neighbors don’t have to be directly connected (okay, this is an overstatement, but for the purposes of this article it will suffice).
BGP is a path vector protocol, which means when BGP neighbors exchange routing information, there are many different pieces of information (vectors) that influence path selection. Some of these vectors include reachable networks, path specific attributes (more about this later), and a list of Autonomous System Numbers (ASN).
ASNs are used by a BGP to define routing domains (similar to EIGRP); typically a company will be assigned a specific personal ASN. A BGP device can then determine how many different external routing domains must be traversed to reach the intended destination simply by looking at the number of different ASNs that exist in the path attribute information. This also makes route loop prevention rather easy, because as long as the local ASN is not seen in a network update, then the path does not contain a loop. For example, say the local ASN is 10 and there are other ASNs that connect to various other routing domains. As long as the ASN 10 does not show up in the path attribute information to a specific destination (as in, go outside and come back through the local ASN), then the path to the destination is loop free.
BGP also includes support for Classless Interdomain Routing (CIDR). This allows networks to be summarized at the highest boundary possible through supernetting. The main advantage to this is that it greatly limits the number of routes that exist in the BGP tables. Just imagine trying to maintain a single routing table that had a route to all existing networks using no summarization.
BGP Path Attributes and Path Selection
As I mentioned, there are large numbers of different path attributes that can be used by BGP to control how the traffic for a specific network is routed. These attributes are ordered so a priority exists if multiple routes to the same destination exist, and these will be analyzed in order until the tie is broken (some minor difference occur depending on the platform vendor).
- Weight – The BGP weight attribute is Cisco-specific and is used to influence how traffic is routed for a specific BGP device. This value does not pass between internal or external BGP neighbors (peers).
- Local Preference – The local preference attribute is used to dictate how traffic prefers to leave a specific BGP ASN. This attribute is passed between neighbors within the same ASN. The highest local preference gets priority.
- Local Routes – Routes which have been sourced from the local router will be preferred over those sourced from other routers.
- Shortest AS_PATH – With BGP, the path is notated by the ASN of the external BGP networks that must be traversed to reach the destination network; e.g. 10 20 30 means that the traffic must pass through ASNs 10, 20, and 30 to reach the destination. If multiple options exist to a specific network, the one with the shortest AS path will be preferred.
- Origin – With origin, BGP is looking for the source of the initial network advertisement, for example if it was redistributed from an IGP, an EGP or through an unknown source. When analyzing this attribute, routes that have originated from an IGP are preferred to those from an EGP, and routes that have originated by an EGP will be preferred over those originated from an unknown source. I < E < ?
- Multi-Exit Discriminator (MED) – The MED is a value that can be injected into a neighboring BGP ASN. This is used when multiple paths exist between two different BGP ASNs. The MED is used to suggest to the neighboring ASN the preferred way to route traffic into their network. The lowest MED value gets priority.
- BGP Neighbor Type – There are two different types of BGP neighborship: internal and external. A BGP neighborship that exists within the same ASN between two devices is considered internal, and a BGP neighborship that exists between devices from different ASNs is considered external. External (or eBGP) routes are preferred to Internal (iBGP) routes.
- IGP metric/next hop – The next attribute uses the IGP metric to the BGP next hop address.
- Oldest External Route – If the contending BGP routes are external then the one which has existed the longest will be preferred
- Lowest Router-ID – The route with the lowest BGP router ID will be preferred
- Lowest Neighbor Address – The route coming through a neighbor with the lowest address will be preferred.
Even broken down like this, BGP is simply a beast; many network engineers can go through their whole networking careers without ever having to deal with a BGP network. For those looking to work at larger enterprises and service providers, however, a close familiarity with BGP is essential. Hopefully the content in this article will get the reader started and begin the long path towards becoming BGP expert.