BGP or Border Gateway Protocol is one of several standardized protocols used to route network traffic on the Internet. BGP is an exterior gateway protocol responsible for exchanging routing and reachability info. Decisions for routing are based on paths, policies, and the rules a network administrator sets for that network.
There is another version of BGP – iBGP or Interior Border Gateway Protocol. This version is used to route within autonomous systems only. BGP refers to the exterior border gateway protocol when used on the Internet. Sometimes, it will be mentioned as BGP, in that case.
History and Operation
The protocol was first standardized in 1989 and has been used since 1994. The protocol has remained relatively unchanged across multiple versions. The current version of BGP is version 4, standardized in 2006. This version supports CIDR addressing, route aggregation, and multiprotocol extensions. The multiprotocol extensions allow BGP to advertise IPv4 and IPv6 routes simultaneously rather than requiring separate protocols.
BGP relies on peers – other BGP routers – configured manually to create a session. Specifically, a TCP session on port 179. BGP is unique in using the TCP as a transport protocol here – other types of connections rely on UDP or, in some cases, raw IP. To keep the BGP connection up, a member of the network connection sends keep-alive messages. In other words, it sends an empty message telling other members to stay connected at regular intervals – by default, 30 seconds. The administrator of the network can configure this interval.
eBGP vs iBGP
The difference between these two types of BGP is mainly the router’s location, which affects how routes are passed from peer to peer. iBGP routers run within one autonomous system. eBGP routers sit on the edge or border of an autonomous system. When a system has multiple peers, then eBGP peers would be at the edge or outside of the network, communicating with the eBGP routers of adjacent autonomous systems. iBGP peers, in this case, would be the internal ones that only communicate with each other rather than outside elements.
Note: An “autonomous system” or AS is a network or set of networks controlled by or for a single entity. A corporate network, for example, may have numerous network segments, all being part of a single AS.
When an eBGP peer finds new routes, they are taught to all other peers on the network. In contrast, if an iBGP peer finds a new route, it will be taught only to eBGP peers, not other iBGP peers. In other words, no matter what, eBGP peers will be taught any new route discovered and established, whereas only some will be introduced to iBGP peers. These rules mean new routes to external addresses are advertised to all internal devices. Conversely, new routes to an internal address are only advertised outside of the AS. This is based on the assumption that an interior routing protocol will already provide access to internal devices.
BGP networks and peers can have multiple different states. Each state signifies something, and most are part of the normal operation process of a BGP connection. The first state is Idle – when in this state, the BGP initializes, refuses connection attempts, and establishes a TCP connection to the peer.
The second stage is Connect – the router has to wait for the TCP connection to complete. When successful, Connect morphs into OpenSent. When not, it repeats the attempt to connect or returns to the beginning to start over.
OpenSent means the BGP sender waits for an ‘open’ message from its peer. The message is then checked for validity – when it’s found valid, the router returns a Keepalive message, then changes the status to OpenConfirm. In this state, the device is waiting for a KeepAlive message from the other party – when it arrives in time, the next state is Established. Otherwise, it transitions back to Idle and starts all over. In other words, after a peer has sent their KeepAlive message, it listens for the same from other peers – and when that second message arrives at its goal, the final state – Established – happens.
In the Established stage, peers can freely send update messages to exchange information about the possible routes between peers. If one of the set timers expires at any point of the process or an error message appears, the affected peer automatically moves into the Idle state and starts over from the beginning. The same thing happens in cases of BGP version mismatches and similar issues.
BGP or Border Gateway Protocol is an exterior gateway protocol designed to advertise routing information between autonomous systems on the Internet. It advertises routes from internal devices to external devices and learns about routes to external addresses to inform routing decisions. BGP is notoriously complex to manage and has a history of abuse in BGP hijacking attacks. However, BGP is a critical part of routing Internet traffic over IPv4 and IPv6.