USD ($)
$
United States Dollar
India Rupee

What is BGP and How Does it Work?

Created by Thrilok Thallapelly in Articles 20 Dec 2024
Share
«What is OSPF and How it Works?

BGP full form is Border Gateway Protocol. It is one of the most important components for the working of the Internet and is a widely used protocol for routing over the Internet.

In this article, we will learn what is BGP and how it works in networking. We will also cover the BGP Port numbers and states to understand the concept better.

As a part of our IT infrastructure training, we have discussed various networking protocols and this article will explain the Border Gateway Protocol in an easy-to-understand way.

Table Of Content

1.0 What is BGP?

1.1 What is Autonomous System (AS)?

1.2 What is BGP Routing?

1.3 What is BGP Port Number?

2.0 What are the BGP Rules?

2.1 What is BGP Neighbor or What is BGP Peering?

2.2 What are BGP States?

2.3 eBGP vs iBGP

2.4 What is BGP Split Horizon?

3.0 How Does BGP Work?

3.1 What are BGP Path Attributes?

3.2 What is BGP Best Path Selection Criteria?

3.3 What is BGP Prefix List?

3.4 What is BGP route map?

3.5 What is BGP Community?

4.0 Where is BGP Used?

5.0 How to Learn BGP?

What is BGP?

BGP stands for Border Gateway Protocol. It is a standardized exterior gateway protocol that facilitates the exchange of routing and reachability information among autonomous systems (AS) on the Internet. 


BGP operates as a path-vector protocol, making routing decisions based on paths, policies, and rules set by network administrators.

Let's understand the autonomous system mentioned earlier.


Live CCNP Enterprise TrainingEnroll in live CCNP Enterprise course to advance skills and get valid certification.Explore course
custom banner static image

What is an Autonomous System (AS)?

Autonomous System (AS) is a group of interconnected networks connected to internet routers that are managed by a single administrative domain, such as a business, organization, or enterprise.

It is assigned by a 2-byte number called ASN or Autonomous Number. These ASNs are exhausted now, so the Internet Engineering Task Force (IETF) came up with a 4-byte ASN.

Type of Autonomous System (AS)

There are three types of Autonomous systems:

1. Multi Home AS - AS connected to two or more Autonomous Systems

2. Stub AS - AS connected to only one Autonomous System

3. Transit AS - AS acts like a link between two or more Autonomous Systems

banner image

BGP Routing

BGP is a path vector protocol, which means it chooses the best route to a destination based on the qualities and path information of a route.

Internet BGP routers exchange these routes which they are aware of with each other across several autonomous systems.

Based on these routes, internet BGP routers build a routing table that displays the most direct route to each destination.


What is the BGP Port Number?

BGP is an application layer protocol that uses TCP at the transport layer. Its TCP port number is 179.

What are the BGP Rules?

Since BGP is the internet protocol, it means some sort of rules must be defined all internet routers should follow them. 

Internet routers use these rules to make decisions about routing data between different networks.

Here are some key aspects of BGP rules: 

banner image


What is BGP neighbor or peering?

Internet routers should know each other before sharing any information.

So first these routers become BGP neighbors or peers with each other if both peers successfully pass BGP authentication(md5 method), you may also be required to perform troubleshooting and only then they start sharing routing information effectively.

Later they also exchange routing updates if there are some changes in the connected networks.

What are BGP States?

Let's learn about BGP states in brief, these are the different phases in the process of routers becoming BGP neighbors. 

1. Idle State: In this initial state, the two routers who want to become neighbors wait for the BGP process to start.

2. Connect State: In this state, TCP connection requests initiate but a 3-way handshake is not completed yet.

3. Active State: Enter into this state when BGP is unable to establish a TCP connection with the neighbor.

4. OpenConfirm State: When a BGP router receives an Open message from its neighbor and also sends Keepalive. 

5. Established State: When both BGP routers receive Keepalive messages from each other. Here they start exchanging routing information.

eBGP vs iBGP

Two main types of Border Gateway Protocol (BGP) are used in the internet networks:

1. External BGP (EBGP):

EBGP is used to exchange routing information between different autonomous systems on the Internet.

In EBGP, routers in different AS establish BGP sessions with each other to exchange routing information and establish the best path to a destination. 

Administrative Distance (AD) value of eBGP is 20.

2. Internal BGP (IBGP):

IBGP is used to exchange routing information within the same autonomous system (AS).

IBGP routers are typically used to propagate routing information between different parts of the same AS, or to provide redundancy within an AS.

IBGP routers do not need to be directly connected to each other, they can be connected via other BGP routers.

Administrative Distance (AD) value of iBGP is 200.

How AS PATH Attribute Handled by eBGP and iBGP

It’s important to remember that although if the two types of BGP are utilized in various ways, they share a common protocol and perform similarly.

The way EBGP and IBGP handle the AS PATH parameter is the major distinction between the two protocols. I cover BGP attributes in the later part of this blog article.

When a route is learned in EBGP, the AS PATH attribute is updated to include the router’s AS number. It helps in loop avoidance in eBGP.

While AS number is not assigned to the AS PATH element in iBGP.

What is Split Horizon in BGP?

Split horizon is a mechanism used in iBGP to avoid routing loops. If an iBGP router receives a route from its iBGP peer, then the iBGP router does not propagate that route to its other iBGP peer. Routes are not passed on to the other peer creating a routing issue. There are some solutions to this problem:

1. Full Mesh: All routers in a AS form iBGP peering with each other.

2. Route Reflector: All routers form iBGP peering with a Route Reflector (RR).

3. Confederation: Large AS is divided into sub-as

How Does BGP Work?

As described previously the Border Gateway Protocol is a routing protocol used to exchange routing information between routers in different or same autonomous systems on the Internet.

BGP routers establish a session, called a BGP neighbor or peer relationship. When two BGP routers establish a neighbor relationship, they exchange their full routing tables with each other.

Each router then uses the information it receives to construct a routing table that shows the best path to each destination. BGP routers use a combination of metrics called BGP attributes to determine the best path to a destination.

banner image

BGP Path Attributes

The optimum route to a destination is chosen by BGP routers via a technique known as BGP Best Path Selection.

Route attributes like the Weight, AS PATH, the origin code, the MED, etc. are used to determine which route to choose. The optimum path is determined by the router to be the one with the lowest metric.

BGP Best Path Selection Criteria

BGP routers select the best path among multiple paths available to reach to the destination networks. The BGP best path selection criteria are based on the attributes associated with each route. The criteria, in order of preference, are as follows:

1. Weight: It's a Cisco-specific attribute, a route with a higher weight is preferred. It is local to a router. 

2. Local Preference: It determines the preference of a route within AS. A BGP route with a higher preference value is preferred. The default local preference value is 500.

3. AS Path Length: An AS is prepended when a route is traversed through various BGP autonomous systems. A BGP route with a shorter AS Path length is preferred.

4. Origin Code: IGP routes are preferred over EGP, and EGP routes are preferred over incomplete routes.

● IGP routes are advertised using interior gateway routing protocols and determined by "i".

● EGP routes are the routes advertised by exterior gateway protocol (Older BGP - never used).

● Incomplete routes are the routes advertised using redistribution and determined by "?".

5. Multi-Exit Discriminator (MED): It determines the preferred exit point for traffic leaving the AS, Lower BGP MED attribute configuration value is preferred.

6. eBGP vs iBGP: eBGP routes are preferred over iBGP routes.

7. IGP metric to Next Hop: A route with a lower IGP metric to the next hop is preferred. 

8. Next Hop: A route with a reachable next hop IP address is preferred.

9. Router ID: BGP uses the Router ID of the router advertising the route. The router with the lowest Router ID is preferred.

10. Cluster ID and Originator ID: They are considered only in the case of route reflectors. A route with the lowest Originator ID is preferred and an Originator ID is used to avoid loops.

What is BGP Prefix List?

Prefix list is a route filtering mechanism used in BGP and with other protocols based on IP address prefixes. A prefix list is created by a name and with a sequence number for example

!

ip prefix-list TEST-LIST seq 10 permit 10.0.0.0/8

ip prefix-list TEST-LIST seq 20 permit 20.0.0.0/8

!

In this prefix list, there is a default implicit deny statement at the end of the prefix list. These prefix list can directly be used in BGP neighbor statement inbound or outbound to filter IP address prefixes. As an example, below is the BGP configuration.

!

router bgp 100

  neighbor 192.168.1.1 remote-as 101

  neighbor 192.168.1.1 prefix-list TEST-LIST out

!

In the above configuration, prefix-list TEST-LIST is applied outbound to allow only the IP address prefixes present in the TEST-LIST prefix list to its BGP neighbor 192.168.1.1

What is the BGP Route Map?

The prefix list can also be called from a route map for example below, there may be many other parameters such as local preference, weight, access-list, med, etc. can be called from a route map. The route map statements are also permitted and denied with a sequence number. 

!

route-map MY-ROUTE-MAP permit 10

 ip address prefix-list TEST-LIST

!

Now this route map then can be applied to the neighbor statement under BGP process. 

!

router bgp 100

  neighbor 192.168.1.1 remote-as 101

  neighbor 192.168.1.1 route-map MY-ROUTE-MAP out

!

In this configuration, route map also has an implicit deny statement in the end. The route-map is applied on neighbor 192.168.1.1 outbound, this route-map has prefix list which is permitting 10.0.0.0/8 and 20.0.0.0/8 only to its neighbor. 

Note: In above case, the result achieved by both i.e. directly applying prefix list and using route-map are same. 

BGP routers also exchange information about the reachability of a destination. This is done through the use of routing updates, which are sent to inform other routers about changes to the routing table.

These updates can include information about new routes that have become available, or routes that have become unavailable.

What is BGP Community?

BGP community is a 32-bit attribute, represented as 16-bit pair value for example 65000:101, first 16-bit value is AS number and other 16-bit value is assigned by administrator. There are the following types of communities.

1. Transitive vs. Non-transitive:

Transitive communities are propagated to BGP neighbors, while non-transitive communities are not. The default behavior is transitive.

2. Well-Known Communities:

There are a few well-known BGP communities with predefined meanings. For example:

No-Export : Prevents the route from being advertised to external BGP peers.

No-Advertise: Prevents the route from being advertised to any BGP peer.

3. Custom Communities:

Network administrators can define and use custom communities based on their specific needs. These communities can be used to implement various policies or convey information about the route.


Where is BGP Used?

Border Gateway Protocol (BGP) is used in several types of networks, including:

1. Internet Service Providers (ISPs): ISPs use BGP to communicate routing data among several Internet autonomous systems. This enables effective traffic routing between various networks and geographies.

2. Enterprise networks: In industrial networks, BGP is also used to exchange routing data across several sites or regions. This enables effective traffic routing within the same organization’s various departments.

3. Data center networks: BGP is used in data center networks to exchange routing information between different parts of the same data center or between different data centers. This allows for efficient routing of traffic and enables features such as load balancing and failover.

4. Service Provider networks: BGP is used by Service providers for efficient traffic routing between different networks and to provide redundancy.

5. Inter-domain routing: BGP is the routing protocol used between different domains of the internet, it’s the only protocol that can be used to exchange routing information between different autonomous systems (AS).

In summary, BGP is widely used in different types of networks such as Internet Service Providers (ISPs), Enterprise networks, Data center networks, Service Provider networks, and mainly used in inter-domain routing on the internet.

How to Learn BGP?

Now you have the basic concepts on what is BGP and How does BGP work, you can go ahead and study more in-depth on the topics covered here and beyond. There are several ways to learn Border Gateway Protocol (BGP), including:

1. Online Courses:

There are many online courses available that cover BGP, several institutes such as Cisco and renowned platforms like Uninets.

These courses typically include live training, video lectures, quizzes, and hands-on lab exercises to help you learn the concepts and gain practical experience.

2. Books:

There are also several books available on BGP, But I recommend the following books which I have personally read, and I consider them the best books on BGP Routing Protocol.

● Internet Routing Architectures by Sam Halabi

● Routing TCP/IP Volume II by Jeff Doyle

These books provide in-depth explanations of the BGP protocol and its configuration and can be used as a reference guide.

3. Training centers:

Some training centers also offer BGP training courses. These courses are usually taught by certified instructors and provide hands-on experience with BGP.

4. Self-study:

You can also learn BGP by studying on your own using the Cisco documentation and other resources available online.

This method requires self-discipline, time management, and a willingness to experiment with BGP in a lab environment.

5. Labs:

Practical experience is crucial to master BGP, you can use software-based routers emulators like Uninets Virtual labs, GNS3, VIRL, or Eve-NG to set up your own lab and practice different BGP scenarios.

You can use the documentation and the knowledge you gained from the previous methods to understand how to configure and troubleshoot BGP on these routers.

It’s important to remember that using a variety of techniques you can learn BGP more effectively. For instance, you may read a book, do practices in lab, can take an online course to enhance your knowledge.

You may join live training where you can Implement your learnings and knowledge in labs.

BGP States: Troubleshoot Active Neighbor»
Thrilok Thallapelly

Thrilok Thallapelly is a senior network consultant who has dedicated his career to the field of networking. He completed Bachelor's degree in Technology in Computer Science from a reputed university in the country. He has always been fascinated by the world of networking and pursued his passion by learning everything he could about routing and ...

More... | Author`s Bog | Book a Meeting

Related Articles

#Explore latest news and articles

What is the BGP Best Path Selection? 12 Nov 2024

What is the BGP Best Path Selection?

Understand BGP best path selection criteria & algorithm based on prefix attributes using weight configuration scenarios on Cisco routers. Read More!
What is VRF lite and How to Configure it? 16 Dec 2024

What is VRF lite and How to Configure it?

What is VRF Lite? Understand step by step configuration of vrf lite on Cisco routers with a practical scenario example. Read More!
BGP Authentication and Troubleshooting 11 Nov 2024

BGP Authentication and Troubleshooting

Learn to Configure BGP Authentication and Troubleshooting Steps on a Scenario based BGP Lab at UniNets.

FAQ

BGP (Border Gateway Protocol) is an exterior gateway protocol used to exchange routing and reachability information among autonomous systems (AS) on the Internet, ensuring efficient packet routing
BGP is considered a Layer 7 protocol because it operates at the application layer, utilizing TCP for reliable communication, although it interacts with multiple OSI layers
The main difference between OSPF and BGP is that OSPF is an interior gateway protocol used within a single AS, while BGP is designed for routing between different ASes
BGP is primarily classified as a Layer 4 protocol since it operates on top of TCP, which is a Layer 4 protocol in the OSI model
The benefits of BGP include its ability to provide redundancy by quickly adapting to route failures and its support for policy-based routing, allowing network administrators to control routing decisions based on defined rules

Comments (0)

Share

Share this post with others

Contact learning advisor

Captcha image
50% Discount Code: NEWY25
50% Discount Code: NEWY25
Happy New Year! Enjoy Courses with Lifetime Access.
Day
Hr
Min
Sec
Grab Discount