Border Gateway Protocol
Border Gateway Protocol (BGP) is the only exterior gateway protocol in use today, and its role is to exchange routing information between organizations. BGP is a standard-based protocol defined in RFC 4271 and is the successor of EGP.
BGP Necessity
BGP is used to route between ASs and is considered a path vector routing protocol. Its metric is based on multiple attributes that you can tune and control in order to affect which path through ASs data is taken (this is, in fact, the routing decision). This is more of a policy based routing approach, and policy routing is very important for ISPs routing traffic between each other for different ASs.
BGP is a classless routing protocol that supports VLSM and summarization (i.e., route aggregation). While IGPs can scale to thousands of routes, BGP can scale to hundreds of thousands of routes, making it the most scalable routing protocol ever developed. Currently, the global BGP routing table has over 300,000 routes.
Another characteristic of BGP is its high stability, which is a result of never having a solid convergence of the Internet routing table (i.e., something is always changing in such a large routing table). BGP is stable enough to handle routing and decision-making at the same time. With BGP, it is all about the enforcement of policies, so it does not use a simple metric value that might be tied to a single parameter (e.g., bandwidth). Instead, BGP has a group of attributes that can be manipulated in order to dictate a particular routing policy.
BGP is used in the following scenarios:
- Transit networks: ISPs that want to provide transit to other destinations on the public Internet
- Multihomed networks: Big enterprise networks that rely heavily on Internet traffic and have sophisticated connectivity requirements with two or more ISPs; BGP allows them to control inbound and outbound routing policies
The two scenarios are depicted in Figure 7.11 below:
Figure 7.11 – BGP Deployment Scenarios
Most of the enterprise networks do not need BGP because of the following reasons:
- The network requires single ISP connectivity and default routing configuration is sufficient. A default route will point to the ISP, so all Internet traffic is routed to that single ISP.
- The memory and CPU resources are limited and do not support a BGP implementation. The global routing table needs more than 1 GB of memory just for storage.
- You would not use BGP if you did not own the IPv4 address space in use. An example would be company addresses that are owned by an ISP that advertizes the address space on the Internet. This is the case for small- and medium-sized organizations.
BGP Functionality
Similar to OSPF, IS-IS, and EIGRP, BGP uses a three-table data structure, as follows:
- Neighbor table: Contains information about adjacency with the peers.
- BGP table: Topology table that contains all prefixes learned from the peers.
- IP routing table: Contains the best routes from the BGP tables.
The devices running BGP will establish peerings in order to build the neighbor table and will then exchange updates to build the BGP table. After the BGP table is built, the best paths for routing information are chosen and are used to build the IP routing table.
BGP allows the following types of peerings to be created (as illustrated in Figure 7.12 below):
- External BGP (eBGP) peerings create BGP peerings with a neighbor that is outside of the AS.
- Internal BGP (iBGP) peerings create BGP peerings with devices inside the AS.
Figure 7.12 – BGP Peering Types
The BGP peering types a route is being sent to and received from will influence the update and path selection rules. An example of this is when eBGP peers are assumed to be directly connected. If they are not, a special command called “ebgp multihop” must be entered in order to let the devices know they are not directly connected so they can establish the BGP peering. This assumption has no equivalent when considering iBGP peerings, where there is no requirement for direct connectivity.
Another example of iBGP versus eBGP behavior is that an eBGP-learned route will not be advertised between iBGP peers because of a special loop-prevention mechanism that prevents an update learned via iBGP to be sent to other iBGP peers. This happens because BGP assumes all routers within an AS have complete information about each other. The following solutions exist in order to solve this issue:
- Configure a full mesh of iBGP peers
- Use BGP route reflectors
- Organize the AS into BGP confederations
The solution that involves a full mesh of iBGP peers is the least preferred because of the increased number of connections. The total number of connections is n*(n-1)/2, where “n” equals the number of BGP routers, so for 1,000 routers you would have 499,500 peerings. This is very hard to implement and maintain, so the route reflector and confederations solutions are recommended instead.
Route reflectors (RR) are nodes that will reflect the iBGP updates to devices that are configured as RR clients. This solution is easy to design and implement and solves the iBGP split-horizon rule. You still have to configure a full-mesh connection between (RR) nodes and normal nodes (i.e., non-route reflector clients), but you do not have to have a full mesh between the RR and its clients. This concept is illustrated in Figure 7.13 below:
Figure 7.13 – BGP Route Reflectors
BGP confederations are more complex than route reflectors and function by creating sub-ASs within the main AS. The connections between sub-ASs behave like eBGP peerings, while the connections inside sub-ASs are pure iBGP peerings. This means that you need full-mesh configuration only inside sub-ASs, where you can also configure route reflectors, so you have a combination of BGP design technologies at your disposal. The concept behind confederations is illustrated in Figure 7.14 below:
Figure 7.14 – BGP Confederations
Note: AS numbers are defined as 16-bit integers that range from 0 to 65535. Sub-ASs are usually assigned private AS numbers, ranging from 64512 to 65535. Due to the exhaustion of public AS numbers, IANA introduced 32-bit AS numbers, which it begun to allocate in the last few years.
BGP Path Vector Attributes
BGP can use multiple attributes in order to define a routing policy, the most important of which are as follows:
- Next hop: This attribute must be present in each BGP update, and it indicates where the traffic should be sent in order to reach a particular destination.
- AS path: This attribute lists all the Autonomous Systems through which the prefix has passed. The AS path is similar to a hop count, except it uses AS numbers and provides more details about the path.
- Origin: This attribute gives information about how the prefix entered the BGP system: directly advertised into BGP with the “network” command or redistributed from other routing protocols.
- Local preference: This attribute can influence the way traffic comes into the AS and the path it takes.
- Multi-Exist Discriminator (MED): MED can influence the way packets leave the AS and the path they take.
- Atomic aggregate: Used when performing BGP summarization.
- Aggregator: Used when performing BGP summarization.
BGP attributes can be grouped into several categories, which can be either well known or optional, with well-known attributes being supported by all BGP vendors and optional attributes being supported only by certain BGP vendors. The categories can also be either mandatory or discretionary, with mandatory attributes being sent in every routing update, while discretionary attributes may or may not be present in routing updates. Another categorization relies on the path attribute’s transitivity, which can be either transitive (it passes between eBGP and iBGP neighbors) or non-transitive (it passes only between iBGP neighbors).
Valid combinations of BGP attributes are as follows:
- Well-known mandatory (next hop, AS path, origin)
- Well-known discretionary (local preference, atomic aggregate)
- Optional transitive (aggregator, community)
- Optional non-transitive (MED)
BGP systems will analyze all of these attributes and will determine the best path to get to a destination based on this very complex decision-making process. Only the best route is sent to the routing table and to the peers. The first step in this process is checking whether the next hop is reachable. If it is not, the route is dropped, but if it is, the decision-making process involves analyzing the next steps:
- Weight (Cisco-specific attribute) – the highest weight is preferred
- Local preference – the highest local preference is preferred
- Locally originated routes – preferred
- AS path – the shortest AS path is preferred
- Origin – routes with the lowest origin type are preferred
- MED – the lowest MED is preferred
- Neighbor type – prefer routes that came via eBGP over those that were learned via iBGP
- IGP metric – if there is still a tie, the lowest IGP metric wins



