Cyberithub

What is BGP (Border Gateway Protocol) | Explained with example

Advertisements

In this tutorial, we will see what is BGP or Border Gateway Protocol and how we are using this protocol in our daily life. BGP is better known as routing protocol for the Internet as it holds the network together by making sure it always find a connection to send the network packets. Border Gateway Protocol (BGP) is an Internet Engineering Task Force (IETF) standard, and the most scalable of all routing protocols.

What is BGP ?

BGP is one of the most powerful routing protocols and frequently used in the enterprise networks. The current standard deployment is BGP V4. BGP is referred as ‘Path Vector’. BGP does maintain a separate routing table which is based on the shortest AS path as it is not built to route within an AS (AS stands Autonomous System). BGP AS are assigned a 16-bit number that varies from 1-65535. Private subset is reserved 64512-65535. BGP utilizes TCP for reliable transfer of its packets, on port 179.

Advertisements

Consider a network, when you have a network router which is connected to another router in the network, it does not know which the best path is to send its data. BGP considers that it can establish the peering with all the other routers, and it chooses the closest router to send its data. This is the general idea of the Border Gateway Protocol (BGP).

 

When to Use BGP

When we have internet with multiple connections, BGP is not preferable as outbound traffic can be handled by OSPF or EIGRP. Now the question is when to use BGP, so we do have some of the circumstances.

Advertisements

a) Multiple connections exist to external AS’s through different providers.
b) Multiple connections exist to external AS through the same provider, but it must connect via a separate routing policy.
c) The existing routing equipment can handle the additional demands.

There are many advantages of the BGP, but the foremost advantage of the said routing protocol is that the controlling of the traffic how it enters the local AS and how does the traffic exist it. That’s why the BGP is very popular routing protocol.

Advertisements

 

BGP Peers (Neighbors)

Now, let’s go in detail for the BGP, For BGP to function, BGP routers called speakers must form a neighboring relationship which is known as peers.

There are two types of BGP neighbor relationship which are as follows:-

Advertisements

iBGP Peers – BGP neighbors within the same autonomous system.
eBGP Peers – BGP neighbors connecting separate autonomous systems.

 

What is BGP (Border Gateway Protocol) | Explained with example 1

In the diagram, Router (B) & Router (C) exists in AS 200 which is certainly going to form an iBGP peer relationship. For understanding, Router (A) does fall in AS 100 and Router (B) exists in AS 200 so this is going to form eBGP peering. That’s the basic understanding of iBGP and eBGP.

Once the BGP peers form neighbors’ relationship, they will share their routing table and any changes made will be forwarded to peers. In general, or default behavior, eBGP peers are a maximum of one hop away. The restriction can be moved by using the eBGP-multi hop.

iBGP peers do not have a hop restriction and are dependent on the underlying IGP of the AS to connect peers together.

A cisco router which is running BGP can run only 1 AS. The IOS will only allow one BGP process to run on a router. The Administrative Distance for eBGP is 20 whereas the AS for iBGP is 200.

 

BGP Peers Messages

When we talk about the BGP peers’ messages, so we get to know that BGP passes through several or different states. This is known as BGP Finite state machine (FSM).

Idle – the initial BGP state
Connect - BGP waits for a TCP connection with the remote peer. If successful, an OPEN message is sent. If unsuccessful, the session is placed in an Active state.
Active – BGP attempts to initiate a TCP connection with the remote peer. If successful, an OPEN message is sent. If unsuccessful, BGP will wait for a Connect Retry timer to expire and place the session back in a Connect State.
Open Sent – BGP has both established the TCP connection and sent an OPEN Message and is awaiting a reply to OPEN Message. Once it receives a reply to OPEN Message, the BGP peer will send a KEEPALIVE message.
Open Confirm – BGP listens for a reply KEEPALIVE message.
Established – the BGP peer session is fully established. UPDATE messages containing routing information will now be sent.

If a peer session is stuck in Active state so this means that no IP connectivity.

 

Configuring BGP Neighbors

What is BGP (Border Gateway Protocol) | Explained with example 2

Now, lets talk about the BGP neighbor’s configuration and what is the process and script for that. The very first or initial step is to enable the BGP process on AS.

RouterB(config)# router bgp 100

Router (B) exists now in AS 100. Neighbor relationships must be established. To configure a neighbor relationship with a router in the same AS (iBGP Peer):-

RouterB(config)# router bgp 100
RouterB(config-router)# neighbor 10.1.1.1 remote-as 100

To configure a neighbor relationship with a router in a separate AS (eBGP Peer):-

RouterB(config)# router bgp 100
RouterB(config-router)# neighbor 172.16.1.2 remote-as 900

To get the stability purpose, the source interface is used to generate the regular updates for a specific neighbor and that can be scripted as:-

RouterB(config)# router bgp 100
RouterB(config-router)# neighbor 172.16.1.2 update-source lo0

RouterC must then point to RouterB’s loopback.

RouterC(config)# router bgp 900
RouterC(config-router)# neighbor 1.1.1.1 remote-as 100

RouterC must have a route to RouterB’s loopback in its routing table.

What is BGP (Border Gateway Protocol) | Explained with example 3

There is another step which needs to be remembered is that BGP by default assumes that external peers are one hop away, so eBGP- Multi hop is enabled. If the concepts are cleared so BGP is very easy to handle and configure in an enterprise network. The BGP is very useful in large networks, generally BGP is being used at ISP level or corporate environment where large number of networking or subnet is involved.

RouterC(config)# router bgp 900
RouterC(config-router)# neighbor 1.1.1.1 ebgp-multihop 2

To authenticate updates between two BGP peers:

RouterB(config)# router bgp 100
RouterB(config-router)# neighbor 172.16.1.2 password CISCO

 

Configuring BGP Timers

To globally adjust the Keepalive and Hold-time timers for all neighbors:-

RouterB(config)# router bgp 100
RouterB(config-router)# timers bgp 30 90

The command shows that the keepalive time is set to 30 seconds, and the timer is set to 90 seconds. To adjust the timers for a specific neighbor (which overrides the global timer configuration):-

RouterB(config)# router bgp 100
RouterB(config-router)# neighbor 172.16.1.2 timers 30 90

 

Viewing BGP Neighbors

What is BGP (Border Gateway Protocol) | Explained with example 4

To view the status of all BGP neighbors:

RouterB# show ip bgp neighbors
BGP neighbor is 172.16.1.2, remote AS 900, external link 
 Index 1, Offset 0, Mask 0x2
 Inbound soft reconfiguration allowed
 BGP version 4, remote router ID 172.16.1.2
 BGP state = Established, table version = 27, up for 00:03:45 
 Last read 00:00:19, hold time is 180, keepalive interval is 60 seconds
 Minimum time between advertisement runs is 30 seconds 
 Received 25 messages, 0 notifications, 0 in queue
 Sent 20 messages, 0 notifications, 0 in queue 
 Inbound path policy configured
 Route map for incoming advertisements is testing 
 Connections established 2; dropped 1
 Connection state is ESTAB, I/O status: 1, unread input bytes: 0 
 Local host: 172.16.1.1, Local port: 12342
 Foreign host: 172.16.1.2, Foreign port: 179

Enqueued packets for retransmit: 0, input: 0, saved: 0

Event Timers(current time is 0x530C294):
Timer           Starts         Wakeups         Next
Retrans           15              0            0x0
TimeWait           0              0            0x0
AckHold           15              13           0x0
SendWnd            0              0            0x0
KeepAlive          0              0            0x0
GiveUp             0              0            0x0
PmtuAger           0              0            0x0

To view the status of a specific BGP neighbor:-

RouterB# show ip bgp neighbors 172.16.1.2

Leave a Comment