Home / Networking Basics / BGP, The Border Gateway Protocol

BGP, The Border Gateway Protocol

BGP Introduction

Historically, there was EGP. then came BGP. BGP is a popular Exterior Gateway Protocol. It falls under neither the distance vector, nor the link state family; it is a path vector protocol.

BGP is a policy-based routing protocol; we can manipulate the routing packets according to various criteria.

BGP is the protocol with the slowest convergence time.

Without tuning, BGP behaves like RIP; path selection occurs based on the hop count, where hops are the autonomous system numbers.

BGP is used as a protocol that interconnects between autonomous systems, such as:

  • multihoming Internet connection: when the company has more than one Internet connection with more than one ISP
  • ISP-to-ISP peering.

Figure: ISP peering © drpeering.net

BGP builds path vectors. A path vector contains:

  1. a path to a network prefixand
  2. a list of path attributes (for example: the ORIGIN attribute which describes how the prefix was introduced into BGP). We’ll discuss them in the BGP Attributes paragraph.

The path is a series of ASN in reverse order.

A BGP router chooses the best path based on its BGP routing policy.

A BGP announcement – aka BGP update message – is an update about one and only one path. It contains the following:

  1. a list of prefixes within the path
  2. the path attributes

Each autonomous system advertises the best path to reach the prefixes of the autonomous system behind it. In the figure, AS2 advertises to AS1 only the best path it has for AS11 prefixes.


BGP updates are triggered and incremental.

BGP Transport method

The BGP connection runs over TCP port 179. And despite that, the only reliability mechanism that BGP has is TCP ACKs.

When designing a network with BGP and you have some filtering in the network (such as a firewall or ACLs), make sure to allow the TCP/179 connection between BGP routers, in both ways, because you don’t know which router will initiate the BGP connection first.

BGP router vs BGP peer

A BGP router is also called a BGP speaker. It’s a router that runs BGP. However, a BGP peer is more than just a BGP router; it has established BGP neighborship with some other BGP routers.

it is recommended to establish BGP peering over loopback interfaces, because loopback interfaces never go down in a network.

BGP packet types

  • Open
  • Keepalive
  • Notification: informs the BGP protocol that something “bad” happened.
  • Update

When the UPDATE messags are exchanged, BGP does not need to exchange the KEEPALIVE messages.

Some BGP connection scenarios


Figure: Multihomed company

When a company is multihomed, there could be one of these BGP connection scenarios:

  1. ISPs send default routes to the company BGP routers. This is obviously the simplest scenario,
  2. ISPs send default routes and a portion of their BGP table.

When you have a connection to a single ISP, there is no need for BGP. A simple default route would suffice.


 BGP neeighborship states

There are four stages before two BGP routers become neighbors:

  • Idle
  • OpenSent
  • OpenConfirm
  • Established

BGP peering agreement

Between a company and an ISP, there could exist a peering agreement. This is a document that describes the BGP configuration between both parties.

For example, an ISP could require network blocks of /18 to be announced by the client enterprise network, as part of the peering agreement.

Types of BGP tables

There are three tables used by BGP. Two of them are typical of BGP:

  • BGP neighbor table: list of peering relationships
  • BGP table: list of BGP prefixes
  • RIB: Routing Information Base. This is the classical routing table we used to see in a router. The best paths of BGP are inserted here.

Methods to advertize a BGP route

You can advertize a BGP route in one of the following ways:

– with the “network” statement
– with redistribution
– with an aggregate route
– with a default route “default-information originate”

Filtering BGP routes

Filtering routes in BGP can be done with one of the following commands:

  • neighbor … prefix-list …
  • neighbor … distribute-list …
  • neighbor … filter-list …
  • neighbor … route-map …

BGP attributes

BGP provides flexibility  in the fact that it can customize individual route properties, while IGPs provide only the capability of customizing the metric (or cost) of the whole protocol. These properties are called attributes.

BGP attributes -aka BGP path attributes– are the massive metrics of BGP. There is about 80 attributes. And they fall under one of these categories:

  • well-known attributes,
  • optional attributes.

BGP route aggregation: it is the mechanismof route summarization, but specific to BGP

The 10 rules of BGP path selection

Before giving the famous list of BGP path selection criteria, the network must have the following properties:

  • Routes are synchronized
  • there is are no AS loops
  • the next hops are valid

Here are the 10 rules for path selection, ordered:

  1. highest Weight
  2. highest Local Preference
  3. existence of route with next hop
  4. shortest AS Path
  5. lowest Origin
  6. lowest MED
  7. EBGP routes are privilieged over IBGP routes
  8. route through the closest IBGP neighbor
  9. prefer the oldest route
  10. lowest neighbor’s Router ID


Leave a Reply

Your email address will not be published. Required fields are marked *


Adsense black background: