BGP: Border Gateway Protocol recap.
BGP is today’s core routing protocol for the Internet. It is used in all service provider environments and inside some Enterprise environments. This article aims to provide a short introdcution into BGP, highlighting some of the protocols more prominent characteristics.
RFC 4271 defines BGP as BGP-4 and states that ‘The primary function of a BGP speaking system is to exchange network reachability information with other BGP systems.’ To exchange this network reachability information, BGP speaking routers need to build a peering session between each other. A BGP peering session is always between 2 routers.
Contrary to a lot of other routing protocols, BGP offers no mechanism to auto-detect or auto-configure its neighbors. To have BGP speakers form a peering session, they have to be manually configured to do so.
To sustain peering sessions, BGP speakers rely on the TCP protocol. Two BGP speakers that have been configured to setup a peering session will start by setting up a TCP connection (port 179) between each other;
After a TCP connection is established, the BGP speakers can use it for the exchange of BGP messages:
By utilizing TCP, BGP speakers are guaranteed reliable communication and by exchanging BGP Keepalive messages, a peer ensures that its neighbor is still functioning properly. Besides the Keepalive message, there are more BGP message types and every message has its own purpose and characteristics.
Another message type is the BGP Update message. BGP speakers can use this message to exchange routing information. Since TCP is providing for reliable communications, BGP speakers only have to send the routing information once and not periodically. This is very unlike many other routing protocols. For example, OSPF periodically refreshes all routing information (LSA refresh). This is regardless of whether or not there was any change. BGP's incremental update strategy conserves bandwidth and processing power.
Whenever a BGP speaker sends routing information using an Update message, they do not simply exchange IP prefixes. BGP speakers exchange prefixes and prefix lengths ( aka NLRI, or Next-Layer-Reachability-Information) together with Path attributes. These path attributes give prefixes additional characteristics. By using policies to manipulate these BGP attributes, BGP can become a very powerful tool allowing for a lot of flexibility in network designs.
BGP is very often called multiprotocol. BGP speakers are capable of signaling to each other what types of address families they support. After conveying this information, they can use one BGP peering session to exchange routing information for multiple address families. For instance, an IPv4 BGP neighbor relationship can be used to signal IPv4, IPv6 and IP-VPN routing information between peers.
BGP speakers distribute routing information within and between autonomous systems. RFC 1930 describes an autonomous system (or AS) as follows: ‘An AS is a connected group of one or more IP prefixes run by one or more network operators which has a SINGLE and CLEARLY DEFINED routing policy.’ The BGP routing protocol knows two types of peering sessions. A distinction is made between an IBGP and an EBGP session;
BGP speaking neighbors that reside in different autonomous systems maintain an EBGP neighbor relationship with each other. Via an EBGP session, an autonomous system can learn prefixes from other autonomous systems as well as advertise its own prefixes to other autonomous systems. BGP neighbors that reside in the same autonomous system maintain an IBGP neighbor relationship with each other. IBGP sessions are used to distribute BGP routing information within an AS.
BGP is an inter-autonomous system path vector routing protocol and for loop detection, BGP is reliant on an attribute called the AS-path. This attribute is a list of all the autonomous systems a prefix has already traversed. If a BGP speaking routers sess its own autonomous system listed in the AS-path, the routing update is ignored.
The picture above illustrates how BGP handles a routing loop. In this example, AS 1 originates prefix information and sends it towards AS2. Here, the information is propagated towards AS 3 which sends it back to AS 1 again. Every time BGP peers exchange prefix information across an EBGP session, the AS-path attribute is updated by the advertising router. The advertising router prepends its own AS . When the prefix information reaches router A, it is rejected. This is because router A can see its own AS listed in the AS-path attribute.
In IBGP, all sessions are between routers in the same autonomous system. Since the AS-path attribute is only updated when prefix information is send across an EBGP session, the loop-detection mechanism that works for EBGP does not work for IBGP. In order to prevent routing loops in an IBGP network, BGP speaking routers will not readvertise IBGP learned routes across an IBGP session. As a consequence, all IBGP speaking routers have to be configured in a full-mesh to assure consistent routing information in the entire autonomous system (there are two scaling mechanisms to counter this).
Take a look at the following example scenario:
This scenario is an illustration of a basic BGP setup. In the example, three routers are forming an AS and they are running OSPF. OSPF is used as an IGP inside the AS. OSPF is taking care of the redistribution of prefix information inside the AS. This prefix information is used by the BGP speakers to setup IBGP peering sessions with each other using their loopback IP addresses. After creating a full mesh of IBGP sessions inside the AS, the EBGP learned prefix information can be distributed across all the routers by means of BGP.
When router D advertises prefix information to router C, Router C will use the IBGP sessions to distribute the information to routers A and B. In most networks, IBGP speakers are configured to change the next-hop attribute, changing it to the IBGP speakers' own loopback IP address. This way, the subnet in use between routers C and D does not need to be distributed via the IGP.
Whenever routers A and B receive packets destined to the 192.168.1.0/24 subnet, they consult their routing table. In their routing table, they will find a BGP route with a next-hop pointing to router C. This will require the router to perform a recursive lookup. The routers will find router C’s address in the OSPF table. The next-hop associated with this route will be used to forward traffic towards 192.168.1.0/24 (more on the next-hop attribute).
For specific information on a BGP topic, please check out the 'Networking protocols - BGP section'.