BGP is a foundational networking protocol that is used to exchange routing information between different networks. It is a crucial protocol as it lets the router determine the best path for data transmission.
In this article, we have explained the Border Gateway Protocol and its working in detail. We have also covered other Important concepts like BGP states, uses, advantages, and disadvantages
In our IT infrastructure training, we have explained various internet protocols like BGP with their practical implementations on real networking devices. If you are interested in building a career in IT networking, you can check out these courses.
BGP stands for Border Gateway Protocol. It is a standardized exterior gateway protocol that allows for the exchange of routing information among Autonomous Systems (AS) on the Internet.
It operates as a path-vector protocol and makes routing decisions based on paths, policies, and rules set by network administrators.
In BGP, an Autonomous System (AS) is a group of IP networks managed by a single organization that follows a unified routing policy. For example, think of your Internet Service Provider (ISP). All the routers and devices within your ISP's network follow the same routing rules and are managed by the same organization. This entire network behaves as a single unit and is considered an Autonomous System (AS).
Each AS is assigned a unique number called an AS Number (ASN), which helps identify it on the Internet. BGP uses these ASNs to track the path that data takes across different networks, known as the AS Path.
This helps routers make smart decisions about the best route for data and prevents routing loops. Autonomous Systems are essential for organizing the internet into manageable sections and enabling efficient communication between service providers, data centers, and large enterprises.
Originally, ASNs were 2 bytes long, but since those are used up, the Internet Engineering Task Force (IETF) introduced 4-byte ASNs.
There are three types of Autonomous systems:
1. Stub AS: A network that connects to only one other AS. It does not pass traffic through to other networks, just sends and receives its own data.
2. Multi-Home AS: A network that connects to two or more ASes, but does not allow traffic to pass through it. It uses multiple connections for redundancy or load balancing, but isn’t a transit point.
3. Transit AS: A network that connects to multiple ASes and allows traffic to pass through it. These are typically ISPs or backbone providers that help route data across 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 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.
BGP neighbors, or peers, are routers that establish a connection to exchange routing information. Two routers can become BGP neighbors after clearing the BGP authentication(MD5 method).
BGP path attributes are the criteria that determine the best path to the destination. Here are some common path attributes that BGP uses in its best path selection criteria.
1. AS_PATH: Lists the Autonomous Systems a route has passed through. BGP prefers a path with a shorter AS_PATH.
2. NEXT_HOP: Specifies the IP address of the next router to reach the destination. Ensures correct forwarding of packets.
3. LOCAL_PREF (Local Preference): Used within an AS to choose the preferred path for outbound traffic. Higher values are preferred.
4. MED (Multi-Exit Discriminator): Suggests to external ASes which path to use when multiple entry points exist. Lower values are preferred.
5. ORIGIN: Indicates how the route was learned (IGP, EGP, or incomplete). Preference order: IGP > EGP > Incomplete.
6. WEIGHT (Cisco-specific): Used to influence route selection on Cisco routers. Higher weight is preferred.
7. Router ID: It is used as a tie-breaker when all other attributes are equal. Lower router ID is preferred.
8. Peer IP Address: It is used as a final tie-breaker, and a lower IP address is preferred.
Read our detailed article on BGP Best Path Selection Criteria.
BGP states are the different phases a router goes through to become a BGP neighbor. There are 6 BGP states:
State | Description |
---|---|
Idle | BGP waits for a start event. Initializes resources and listens for TCP connections. |
Connect | BGP tries to establish a TCP connection with the peer. If successful, moves to OpenSent. |
Active | If the TCP connection fails in the Connect state, BGP retries here. If successful, moves to OpenSent. |
OpenSent | BGP sends an OPEN message and waits for one from the peer. Validates parameters. |
OpenConfirm | BGP waits for a KEEPALIVE message to confirm the session. |
Established | BGP session is fully established. Peers exchange UPDATE, KEEPALIVE, and NOTIFICATION messages. |
There are two types of Border Gateway Protocol (BGP)- External BGP and Internal BGP.
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.
The Administrative Distance (AD) value of eBGP is 20.
IBGP is used to exchange routing information within the same autonomous system (AS). IBGP routers propagate routing information between different parts of the same AS. IBGP routers do not need to be directly connected, as they can be connected via other BGP routers.
The Administrative Distance (AD) value of iBGP is 200.
Although EBGP and IBGP are used differently, they both follow the same BGP protocol and behave similarly in most aspects. The key difference lies in how they handle the AS_PATH attribute.
In EBGP, when a route is received, the router adds its own AS number to the AS_PATH. This helps prevent routing loops by showing the path a route has taken through different autonomous systems.
In IBGP, the AS_PATH is not modified because the route stays within the same autonomous system. This allows internal routers to share routes without affecting loop prevention mechanisms.
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 an AS form IBGP peering with each other.
2. Route Reflector: All routers form iBGP peering with a Route Reflector (RR).
3. Confederation: A Large AS is divided into sub-ASs
A 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
In this prefix list, there is a default implicit deny statement at the end of the prefix list. These prefix lists can be directly used in the BGP neighbor statement, inbound or outbound, to filter IP address prefixes. As an example, below is the BGP configuration.
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
A BGP Route Map is a tool that can manipulate and control BGP routing decisions by applying conditions and actions to routes. 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.
Now, this route map can be applied to the neighbor statement under the BGP process.
In this configuration, the route map also has an implicit deny statement at the end. The route-map is applied on neighbor 192.168.1.1 outbound, this route-map has a prefix list which permits 10.0.0.0/8 and 20.0.0.0/8 only to its neighbor.
Note: In the above case, the result achieved by both, i.e., directly applying the prefix list and using route-map are same.
BGP community is a 32-bit attribute, represented as a 16-bit pair value, for example, 65000:101. The first 16-bit value is the AS number, and the other 16-bit value is assigned by an administrator.
There are three types of BGP 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.
● BGP is designed to handle thousands of routes, making it ideal for large networks like the Internet.
● Network administrators can define routing policies using attributes like AS_PATH, MED, and LOCAL_PREF to control traffic flow.
● It supports both internal (iBGP) and external (eBGP) routing, allowing for complex network topologies.
● Allows administrators to fully control route selection using route maps, prefix lists, and filtering mechanisms.
● BGP works across different vendors and platforms, making it suitable for heterogeneous network environments.
Border Gateway Protocol (BGP) finds its application in various network settings, like:
1. Internet Service Providers (ISPs): ISPs use BGP to communicate routing data among several Internet autonomous systems.
2. Enterprise networks: In industrial networks, BGP is also used to exchange routing data across several sites or regions.
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.
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 is the only protocol that can be used to exchange routing information between different autonomous systems (AS).
Now that you have the basic concepts of what BGP is and how BGP works, 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.
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 the 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.
5. Labs: Practical experience is crucial to master BGP. You can use software-based router emulators like Uninets Virtual Labs, GNS3, VIRL, or Eve-NG to set up your lab and practice different BGP scenarios.
BGP is essential for internet routing, connecting different networks through Autonomous Systems (AS). It uses path attributes and best path selection criteria to ensure optimal routing.
Understanding BGP's states, neighbor relationships, and tools like Prefix Lists and Route Maps is crucial for network stability. Continuous learning about BGP helps maintain efficient network infrastructures.
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