BGP protocol: what is it used for

BGP protocol: what is it used for ?

The Border Gateway Protocol (BGP) was designed to support routing between autonomous systems on very large networks. It allows subnets to share accessibility information in this ecosystem. Thus, the mechanism is perfectly suited for the Web.

It is the only external routing protocol currently used by the many networks connected to the Internet.

How the BGP protocol works ?

The BGP protocol is a crucial part of the ASNs interactions between online autonomous systems. is a protocol that allows to announce the presence, the IP addresses and the interconnection of networks. The mechanism also provides routers with the routes that can be used for the routing of data packets.

However, these instructions must be up to date to ensure the flow of information.

A problem with BGP update A problem that caused the Facebook outage in October 2021 . After the changes, the protocol did not announce the new route to the remote servers of the group. Therefore, the other networks could no longer find its different platforms (Facebook, Messenger, Instagram, WhatsApp…). These services had become unavailable for all AS (Autonomous Systems).

As a reminder, a autonomous system is a network under the same authority. It can be an ISP, a corporate network, a public infrastructure, a Cloud operator… In any case, each entity applies the same routing policy and is identified by an ASN (Autonomous System Number).

An AS is supposed to control its IP address pool (prefixes) and know how to connect to other networks. In addition, each ASN must transmit the routing routes of its DNS prefixes to the entire Web via BGP. Thus, all online systems will be able to find and join the network linked to the ASN.

What are the other routing protocols ?

The BGP protocol plays the role of gateway for exchanging routing information between ASes. It is thus a EGP (Exterior Gateway Protocol). On the Internet, this category is currently limited to BGP.

This external routing protocol was the successor of ARPANET’s EGP and GGP (Gateway-to-Gateway Protocol). Besides BGP, there are a myriad of routing protocols on the Web.

Although essential, IP (Internet Protocol) is is not well known as a routing protocol. It allows to specify the source and destination of network packets. The IP header is used to identify the destination of each packet at the level of routers.

The other protocols cover the internal routing of the AS. The IGP (Interior Gateway Protocol) category includes :

  • OSPF (Open Shortest Path First) protocol;
  • RIP (Routing Information Protocol) ;
  • IGRP (Interior Gateway Routing Protocol);
  • EIGRP (Enhanced Interior Gateway Routing Protocol);
  • Integrated IS-IS (Integrated Intermediate System to Intermediate System).

OSPF is today part of the protocols most used by network routers. It allows to identify the fastest (and possibly shortest) routes to transmit packets to the destination. RIP protocol is also common within ASes.

Here, routers favor the shortest routes by counting the number of hops (passages from one network to another).

What are the other routing protocols?

How can two BGP routers establish a neighbor relationship ?

A BGP router protocol must create a TCP session to establish a relationship with its neighbor. Both can then be communicate via port 179. During the connections, they will be identified by their respective router ID. This is a unique four-byte identifier to differentiate between routers in an AS.

THE ID used corresponds most often to therouter’s IPv4 (or IPv6) loopback address.

BGP operates in two modes, namely eBGP (BGP exterior) and iBGP (BGP interior). The latter is used within the AS as a IGP dynamic. However, its function remains oriented towards exchanges with other autonomous systems. The internal routing is mainly aimed at maintain external connection in case of physical link interruption.

It is based on logical IP addresses (loopback).

With a eBGP direct routing, the session is broken simultaneously with the physical links. Thus, the prefixes learned in the meantime will be deleted and will disappear from the routing table. This mode is usually based on local networks or point-to-point connections.

Moreover, routers often set the TTL of packets to 1 for this type of session.

Once matched, the BGP neighbors will be able to share information about supported routes. They will also exchange various attributes related to these networks. Concretely, the creation of a neighborhood relation allows to avoid loops and to optimize the routing choice of the transmitted packets.

This solution improves the responsiveness of the network and speeds up data transmission.

How can two BGP routers establish a neighbor relationship?

How to configure the BGP protocol ?

The configuration of the BGP protocol depends basically on the network topology. In any case, you should configure the routers manually after opening the TCP session. Here are the basic commands, for example to create an eBGP with lookback between routers R1 and R3:

Router 1 :

  • R1>enable
  • R1#config
  • R1(config)#loopback0
  • R1(config-if)#ip address [IP address loopback0]
  • R1(config-if)#no shutdown
  • R1(config)#interface serial 0/0/0
  • R1(config-if)#ip address [IP address router 1]
  • R1(config-if)#no shutdown
  • R1(config-if)#exit
  • R1(config)#router bgp [ASN of R1]
  • R1(config-router)#neighbor [IP address of R3 neighbor] remote-as [ASN of R3]
  • R1(config-router)#neighbor [IP address neighbor R3] update-source loopback0
  • R1(config-router)#end
  • R1#

Router 3 :

  • R3>enable
  • R3#config
  • R3(config)#loopback1
  • R3(config-if)#ip address [IP address loopback1]
  • R3(config-if)#no shutdown
  • R3(config)#interface serial 0/0/0
  • R3(config-if)#ip address [IP address router 3]
  • R3(config-if)#no shutdown
  • R3(config-if)#exit
  • R3(config)#router bgp [ASN of R3]
  • R3(config-router)#neighbor [R1 neighbor IP address] remote-as [R1 ASN]
  • R3(config-router)#neighbor [R1 neighbor IP address] update-source loopback1
  • R3(config-router)#end
  • R3#

It is enough to remove the lines associated with the loopback for direct connections. On the other hand, the commands are globally the same on a neighbor relationship in iBGP mode. The ASN will only be identical for R1 and R3, because they belong to the same network.

You can also use the OSPF protocol, if you want to configure a loopback between two routers of the same AS. To do this, enter the Router 1 :

  • R1>enable
  • R1#config
  • R1(config)#interface loopback 0
  • R1(config-if)#ip address [router 1 IP address]
  • R1(config)#router ospf 1
  • R1(config-router)#network [loopback IP address] area 0
  • R1(config-router)#end
  • R1#

Repeat the operation on router R2 :

  • R2>enable
  • R2#config
  • R2(config)#interface loopback 0
  • R2(config-if)#ip address [IP address router 2]
  • R2(config)#router ospf 1
  • R2(config-router)#network [loopback IP address] area 0
  • R2(config-router)#end
  • R2#

In practice, there are a myriad of possible combinations with as many loopbacks as needed. However, be careful about the correspondence of the addresses.