BGP Border Gateway Protocol Concepts

BGP (border gateway protocol) is a routing protocol used in internet. Entire public subnets are given to various ISPs and allocated with an AS (autonomous system) number. Now these various subnets are interconnected and the job to find out which IP subnet is where and how to reach that subnet is done by BGP.

BGP can be used on internal network as well. The AS numbers (1 – 65535) are divided into two categories:

  1. Public AS number (1-64511)
  2. Private AS number (64512-65535)

BGP neighbors type: BGP have two type of neighbors.

  1. External BGP (EBGP) : Neighbor relationship between routers in different AS.

    EBGP
  2. Internal BGP (IBGP) : Neighbor relationship between routers in different AS

    BGP border gateway protocol - IBGP

BGP Timers: The timers need not to be same to form the neighbor relationship.

  1. Keep alive timer: The timer determines how frequently a router sends BGP keep alive messages. 60 Seconds is default value.
  2. Hold timer: The timer determines how long a router can keep the neighbhorship in absence of keep alive messages. 180 Seconds is default value.

BGP messages: There are 4 types of messages in BGP. It uses TCP protocol for communication and uses TCP port 179.

Open The message is used to open BGP communication session between Peers.
This is the first message sent by each side once 3 way handshake is complete.
Once both sides have confirmed receipt of the open message then other message get exchanged.     
Keepalive Notify the BGP peer that device is active. 
Update Used to exchange routing information, such as addition of new routes or withdraw of previously announced routes.     
Notification Message is used to close an active session. 

BGP Router ID selection: BGP uses few of the criteria to select router ID

  1. Manually Configured Router ID in the BGP configuration.
  2. Highest IP address of an up loopback interface at the start of BGP process.
  3. Highest IP address of an up interface at the start of BGP process.

BGP neighbor formation conditions:

  1. The BPG packets must be received from source IP address mentioned in the BGP neighbor command.
  2. The ASN should match with the ASN configured for the neighbor.
  3. The Router IS should be unique.
  4. The authentication should pass.

BGP States: There are total 6 states in BGP.

Idle 1> In this state BGP (border gateway protocol) resources are initialized.
2> BGP start listening for incoming connections.
3> BGP initiates a TCP connection to the peer. 
Connect 1> BGP waits for 3WHS (3 way handshake) to complete.
2> If the handshake is complete it will send open message and move to OpenSent state.
3> If 3WHS unsuccessful then it will continue in Active state. 
Active 1> BGP tries to connect to peer by initiating another TCP connection.
2> If neighbor is stuck in open state that means TCP connection is not forming it could be a connectivity issue. 
Open sent 1> Wait to receive an OPEN message from the peer.
2> If the Open messages do not have any errors, the Hold Time is negotiated (using the lower value)
3> A KeepAlive message is sent (assuming the value is not set to zero).
4> The connection state is then moved to OpenConfirm. 
Open confirm 1> BGP waits for a keepalive message from its peer.
2> If received before the timeout expires, BGP moves to the Established state. Otherwise, BGP transitions to Idle. 
Established Both peers exchange UPDATE messages. If there is an error within any of the UPDATE messages, the BGP peer will send a NOTIFICATION message and enter the Idle state. 

BGP path attributes (PA): In case none of the attributes are set explicitly then BGP uses AS_Path as default metric to select a path. AS_Path represents sequence of AS through which a packet must travel to reach to the destination.

Priority Attribute NameAttribute NameSignificance
Weight 1> Cisco proprietary, only locally significant.
2> Applied to inbound routes and tells what is the best outbound path.
3> Highest weight is preferred. 
4> Default value for weight is 0 for routes learned from neighbors and 32768  for local originated routes.
5> Weight can be set per neighbor.
6> Weight can be set per subnet wise as well with the help of route-map
Local 
Local Preference Local preference control how the traffic exits the AS.
1> Used within an autonomous system.
2> Exchanged between iBGP peers.
3> Highest local preference is preferred. 
4> Default value is 100.
Exchanged between iBGP peer. 
Originate 1> Locally originated routes are preferred. Locally originate route means next hop is 0.0.0.0  
AS path length Path with shortest AS path length is preferred.  Exchanged
Origin code There are three type of origin code in BGP
i (IBGP), e (EBGP) and ? (Incomplete)  
1> IGP – Advertised using network command.
2> EGP – Not seen anymore 
3> Incomplete – Redistributed.  
 
MED (Multi-exit Discriminator ) or Metric MED controls how the traffic entered into the AS.  
1> Lowest MED is preferred.
2> Exchanged between the peers. 
Exchanged within  AS. 
eBGP path over iBGP path   
Shortest IGP path to BGP next hop Prefer the path within the autonomous system with the lowest IGP metricto the BGP next hop.  
Oldest path Prefer the path we have received first.  
10 Router ID Prefer the path with lowest BGG neighbor router ID.  

1 thought on “BGP Border Gateway Protocol Concepts”

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.