What Is Border Gateway Protocol in Networking?
Also known as: Border Gateway Protocol, BGP, BGP routing, CCNA BGP, Network+ BGP
On This Page
Quick Definition
BGP is the system that internet service providers and large networks use to share information about how to reach different parts of the internet. It decides the best path for data to travel from one network to another across the world. Think of it as the postal service for the internet, figuring out which roads to use to deliver your data to the right address.
Must Know for Exams
Border Gateway Protocol appears in several major certification exams, most notably the Cisco CCNA and CCNP, as well as the CompTIA Network+. For the CCNA exam, BGP is tested as part of the IP connectivity domain. Candidates must understand the basic concepts of BGP, including autonomous systems, the BGP path selection process, and the difference between internal BGP and external BGP. The exam does not require deep configuration knowledge of BGP for the CCNA level, but you should be able to explain how BGP works and why it is used in large networks.
For the CCNP Enterprise exam, BGP is a significant topic. You will need to know how to configure BGP on Cisco routers, manipulate path selection using attributes like local preference and AS path prepending, and troubleshoot common issues. The exam may include multiple-choice questions about the BGP states: idle, connect, active, opensent, openconfirm, and established. You must also understand the BGP decision process and the order of attributes that influence route selection. For instance, you might be asked which attribute is considered first in the best path selection algorithm when comparing two routes.
In the CompTIA Network+ exam, BGP is covered in the networking fundamentals domain. It is presented as the primary exterior gateway protocol used on the internet. The exam expects you to differentiate BGP from interior gateway protocols like OSPF and EIGRP. You may get a scenario question where a company has two ISPs, and you need to choose the appropriate protocol for multi-homing. The correct answer is BGP because it handles routing between different autonomous systems. Network+ also touches on BGP security concerns like route hijacking.
For the Juniper JNCIA and JNCIS exams, BGP is also covered, though the configuration syntax differs. The core concepts of AS numbers, path attributes, and route selection remain the same. Regardless of the vendor, exam questions often test your understanding of BGP as a path-vector protocol, its reliance on TCP, and its role in internet routing. Questions may ask which protocol is used to exchange routes between ISPs, or what attribute BGP uses to prevent routing loops. The answer to the loop question is the AS path attribute. Another common question is to identify the port number for BGP, which is TCP 179. Because BGP is a complex topic, many exam questions focus on basic definitions and comparisons. Mastering these basics will help you answer correctly and avoid traps.
Simple Meaning
Imagine the internet as a giant network of highways connecting many different cities. Each city represents an autonomous system, which is a large network run by an internet service provider, a company, or a university. BGP is the protocol that acts like a set of road signs and traffic controllers for these cities.
When a person in New York wants to send an email to someone in Tokyo, the data does not travel in a straight line. It hops from one city to another, passing through several autonomous systems along the way. BGP is responsible for deciding which route the data should take.
It does this by having each city (autonomous system) announce to its neighboring cities which destinations it can reach. For example, the city of New York might say, I can reach the Tokyo area, and I know the best way is through Los Angeles and then across the Pacific. BGP collects all these announcements and builds a routing table, which is like a giant map of the entire internet.
When a packet of data needs to be sent, BGP checks this map and chooses the best path based on policies, not just the shortest distance. Network administrators can set rules that prioritize certain paths for cost, speed, or security reasons. So BGP is not just a simple highway map; it is a policy-driven system that allows network operators to control how their traffic flows across the global internet.
This makes BGP incredibly powerful but also vulnerable to mistakes or malicious attacks, because one misconfigured router can accidentally redirect traffic for the entire world. In simple terms, BGP is the glue that holds the internet together, allowing different networks to talk to each other seamlessly.
Full Technical Definition
Border Gateway Protocol is a path-vector routing protocol that operates at the core of the internet. It is used to exchange routing and reachability information between autonomous systems. An autonomous system is a collection of IP prefixes under a single administrative domain, identified by a unique AS number. BGP is classified as an exterior gateway protocol, in contrast to interior gateway protocols like OSPF or EIGRP which operate within a single AS. The current standard version is BGP-4, defined in RFC 4271.
BGP uses TCP port 179 for reliable transport, which ensures that routing updates are delivered without loss. When two BGP routers establish a connection, they first complete a three-way handshake to form a TCP session. After that, they exchange open messages to negotiate capabilities and version. Once the session is established, they exchange their full routing tables using update messages. After the initial exchange, only incremental updates are sent when routes change. BGP routers also send keepalive messages periodically to verify that the session is still alive.
BGP makes routing decisions based on a set of attributes attached to each route. The most important attributes include AS path, next hop, local preference, multi-exit discriminator, and community strings. AS path is a list of AS numbers that a route has traversed, which is used to detect loops. Local preference indicates how preferred a route is within an AS. The multi-exit discriminator suggests which path to use when multiple connections exist between the same two ASes. BGP routers apply a best path selection algorithm that evaluates these attributes in a specific order. The algorithm first prefers routes with the highest local preference, then the shortest AS path, then the lowest origin type, and so on.
In real IT environments, BGP is implemented on network devices like routers and layer 3 switches. Service providers use BGP to exchange routes with customers and other providers. Enterprises may use BGP when they have multiple connections to different ISPs for redundancy. BGP is also used internally in large data centers for traffic engineering. Network engineers configure BGP using commands on devices like Cisco IOS, Juniper JunOS, or open-source software like FRRouting. Configuration involves specifying the local AS number, defining neighbor relationships, and setting policies using route maps and prefix lists. BGP is stateful and maintains a table of all known routes, called the BGP table, separate from the routing information base used for forwarding.
BGP is susceptible to security issues because it relies on trust between peers. There is no built-in mechanism to verify the authenticity of route announcements. This has led to incidents like route hijacking and prefix leaks. To mitigate these risks, technologies like Resource Public Key Infrastructure and BGPsec have been developed, though adoption is still limited. For certification exams, understanding BGP states, attributes, and the best path selection algorithm is critical. The protocol is essential knowledge for the CCNA, CCNP, and Network+ certifications.
Real-Life Example
Think of BGP like the international postal system. Every country has its own postal service, which is like an autonomous system. Each postal service knows how to deliver mail within its own borders. But when you want to send a letter from the United States to Japan, the US postal service cannot deliver it alone. It must hand the letter to Japan's postal service at the border. BGP is the agreement between these postal services about how to hand off mail and which routes to use.
Now imagine that the US Postal Service has a central office in New York that knows all the routes to Japan. That central office is like a BGP router. It receives announcements from Japan's postal service saying, I can accept mail for all addresses in Japan. For efficiency, the US office might decide to send all Japan-bound mail through a hub in Los Angeles, because that is the shortest path across the Pacific. But if the Los Angeles hub is overwhelmed, the US office might reroute mail through Seattle. That decision is based on policies like cost, speed, or reliability. BGP works exactly like this for internet traffic.
If you order a product from a website hosted in Japan, your internet service provider uses BGP to decide which path your request should take. It might go through a transit provider in the US, then across an undersea cable to Japan, then through a local ISP to reach the web server. BGP makes that decision in milliseconds by consulting its routing table. The table is built from all the announcements that other BGP routers have made. If a cable breaks, the Japanese postal service announces a new route, and the US router updates its table. This is how the internet remains resilient even when parts of it fail.
Why This Term Matters
BGP matters because it is the protocol that makes the internet work as a single, global network. Without BGP, every network would be an isolated island. Internet service providers could not exchange traffic, and you could not visit a website hosted on a different provider. BGP is the mechanism that enables interconnection between thousands of independently operated networks. It is the reason a user in Brazil can access a server in Iceland within seconds.
In real IT work, BGP is critical for network engineers who design and manage large-scale networks. If you work for an ISP, a cloud provider, or a large enterprise with multiple internet connections, you will need to configure and troubleshoot BGP. For example, a company with two internet links for redundancy uses BGP to advertise its IP addresses to both providers. If one link fails, BGP automatically withdraws the route and traffic shifts to the other link. This ensures high availability for the company's online services.
From a cybersecurity perspective, BGP is a double-edged sword. It is essential for traffic steering, but it can be exploited. Attackers can hijack BGP routes to intercept traffic, redirect users to fake websites, or conduct denial of service attacks. Understanding BGP security is vital for professionals responsible for protecting network infrastructure. Techniques like prefix filtering, route authentication, and RPKI are used to reduce risks. For system administrators who manage cloud environments, BGP is used in conjunction with VPNs and direct connect services. For example, Amazon Web Services uses BGP to exchange routes with customer on-premises networks over a VPN connection. Knowing BGP helps you design hybrid cloud architectures that are both efficient and secure. Ultimately, BGP is a foundational skill for anyone pursuing a career in networking or IT infrastructure.
How It Appears in Exam Questions
Exam questions about BGP come in several distinct forms. The first is the definition question. You might see a sentence completion like: The protocol used to exchange routing information between different autonomous systems is called ______. The answer is BGP. Or you might be asked to choose between OSPF, EIGRP, BGP, and RIP in a scenario where two different ISPs need to exchange routes. The correct answer is BGP because it is the only exterior gateway protocol among the options.
The second type is the characteristic question. For example, you could be asked which transport protocol and port BGP uses. The correct answer is TCP port 179. Another common question asks which BGP attribute prevents routing loops. The answer is AS path. These questions test your memory of specific facts about BGP.
The third type is the scenario question. In the CompTIA Network+ exam, you might be given a scenario where a company with two internet connections experiences a failover delay. The question asks which protocol they should use to reduce the delay. The answer is BGP because it can dynamically reroute traffic when a link fails. In the CCNA exam, you might see a scenario showing two routers in different ASes that need to exchange routes. You will be asked to identify the correct configuration command to establish a BGP neighbor relationship, such as neighbor 192.168.1.1 remote-as 65001.
The fourth type is the troubleshooting question. For the CCNP, you might be shown an output from show ip bgp summary and asked to identify why a BGP session is stuck in the active state. Possible reasons include incorrect AS number configuration, a firewall blocking port 179, or a mismatch in the BGP version. You will need to pick the most likely cause based on the output.
The fifth type is the attribute order question. You may be asked to arrange the BGP path selection steps in the correct order. For instance, the first step is to prefer the route with the highest weight, then highest local preference, then shortest AS path, and so on. Some exam questions also test the difference between iBGP and eBGP. You might be asked which protocol requires a full mesh of neighbors inside an AS, and the answer is iBGP because of the split horizon rule. By understanding these question patterns, you can prepare effectively for any exam that covers BGP.
Practise Border Gateway Protocol Questions
Test your understanding with exam-style practice questions.
Example Scenario
A small e-commerce company called ShopFast operates a website that is hosted in a data center. ShopFast uses a single internet service provider to handle all its traffic. One day, a technician at ShopFast decides to improve reliability by connecting to a second ISP.
After the second connection is installed, the network has two paths to the internet. However, the websites customers are not automatically using both links. Some customers experience timeouts because traffic gets stuck on one link while the other remains underutilized.
The network administrator realizes that the company needs a protocol to manage traffic across both internet connections. The administrator configures BGP on the company's edge router. ShopFast has its own public IP addresses and obtains an autonomous system number from the regional internet registry.
The administrator then sets up BGP peerings with both ISPs. The router begins exchanging routing information with each ISP. Now BGP selects the best path for incoming traffic based on the route attributes.
If one ISP link fails, BGP automatically withdraws the route and traffic shifts to the other ISP. The company now has automatic failover and load balancing. This scenario shows how BGP is used to connect multiple ISPs and maintain internet connectivity without manual intervention.
Common Mistakes
Thinking BGP is exactly like OSPF or EIGRP.
OSPF and EIGRP are interior gateway protocols designed for single autonomous systems. They determine the shortest path based on metrics like bandwidth or cost. BGP is a path-vector protocol that uses policies and path attributes to make decisions between different autonomous systems. It does not use a metric like cost; it uses attributes like AS path length and local preference.
Remember that BGP is used between different organizations (ASes), while OSPF is used inside a single organization. BGP is policy-driven, not metric-driven.
Confusing the BGP port with other protocol ports.
BGP uses TCP port 179. Some learners mistakenly think it uses UDP or port 80. Because BGP relies on reliable delivery of routing updates, it uses TCP. Using the wrong port in a configuration will prevent the BGP session from establishing.
Memorize that BGP uses TCP port 179. Associate TCP with reliability and BGP's need for error-free routing updates.
Believing that BGP automatically chooses the fastest path.
BGP does not use bandwidth or delay to choose the best path. Instead, it uses a complex decision process that prioritizes administrative policies. The shortest AS path is often preferred, but that does not necessarily mean the fastest route. Network operators can override the default behavior using attributes like local preference.
Understand that BGP is about policy, not speed. The best path is the one that matches the administrator's rules, which might prioritize cost or reliability over speed.
Assuming BGP only runs on the internet core.
While BGP is crucial for the internet backbone, it is also used in private networks. Large enterprises and data centers use BGP for multi-homing, VPN routing, and even internal load balancing. For example, MPLS VPNs often use BGP to distribute VPN routes across a provider network.
Recognize that BGP is versatile. It is used wherever multiple administrative domains interact, not just on the public internet.
Forgetting that iBGP requires a full mesh of neighbor connections.
Inside an autonomous system, iBGP routers must be fully meshed because iBGP does not advertise routes learned from one iBGP neighbor to another iBGP neighbor. This is the iBGP split horizon rule. If you do not create a full mesh or use route reflectors, some routers will not learn all routes.
When designing iBGP, either configure a full mesh of neighbor relationships or use route reflectors to propagate routes without a full mesh.
Exam Trap — Don't Get Fooled
In a multiple-choice question, the exam presents a scenario where a router learns two routes to the same destination via BGP. One route has an AS path length of 3, and the other has an AS path length of 5. The question asks which route will be preferred.
Many learners choose the route with AS path length 3 because they remember that shorter AS path is preferred. However, the trap is that the exam might include a higher local preference on the route with AS path length 5. Local preference is evaluated before AS path length, so if the local preference is higher on the route with AS path length 5, that route will be chosen.
Memorize the full order of BGP path selection: highest weight, highest local preference, locally originated routes, shortest AS path, lowest origin type, lowest MED, eBGP over iBGP, lowest IGP metric to next hop, and lowest router ID. Always check if the question provides any of the higher priority attributes before jumping to AS path length. In exam questions, read every detail of the scenario to see if local preference or weight is mentioned.
Commonly Confused With
OSPF is an interior gateway protocol used within a single autonomous system. It calculates the shortest path based on link cost, while BGP is an exterior gateway protocol used between different autonomous systems and makes decisions based on policies and path attributes.
In a company network, OSPF routes traffic between the office LAN and the data center. BGP is used when that company connects to two different ISPs to reach the internet.
EIGRP is a Cisco proprietary interior gateway protocol that uses metrics like bandwidth and delay to determine the best route within a single AS. BGP is a standard protocol used between ASes and does not use bandwidth or delay in its default path selection.
A small business using only Cisco routers might run EIGRP internally. If that business later purchases a second internet connection from a different ISP, it would need BGP to manage the two links.
RIP is a distance-vector protocol that uses hop count as its metric and has a maximum of 15 hops. BGP uses AS path length as one of many attributes and has no hop limit. RIP is simple and used in small networks, while BGP is complex and used for global internet routing.
A home network might use RIP for simplicity. But the backbone of the internet uses BGP to handle thousands of networks across continents.
Static routing requires a network administrator to manually configure each route. BGP dynamically learns and exchanges routes with neighboring networks, automatically adapting to changes without manual intervention.
A small office with a single ISP might use a static default route to reach the internet. A large university with connections to two different ISPs would use BGP to automatically fail over if one link goes down.
Step-by-Step Breakdown
Establish a TCP Connection
Two BGP routers first establish a TCP session on port 179. This ensures reliable delivery of all BGP messages. The routers exchange SYN, SYN-ACK, and ACK packets to open the connection. Without this step, no BGP information can be exchanged.
Exchange Open Messages
After the TCP session is established, each router sends an open message. This message includes the BGP version, the local AS number, the hold time, and the BGP identifier. The routers verify that the AS numbers and other parameters are compatible. If they match, the session moves to the open confirm state.
Exchange Keepalive Messages
Once the open messages are accepted, each router sends a keepalive message to confirm that the session is established. Keepalive messages are then sent periodically (typically every 30 seconds) to keep the session alive. If a keepalive is not received within the hold time, the session is considered down.
Exchange Full Routing Table
After the session is established, the routers exchange their entire BGP routing tables using update messages. Each update contains a list of advertised routes and any withdrawn routes. This initial exchange can be large on the internet core, but it is a one-time event.
Send Incremental Updates
After the initial exchange, only changes are sent via update messages. If a new route becomes available or an existing route is withdrawn, the router sends an update to its neighbors. This incremental approach minimizes network overhead and allows BGP to converge quickly after topology changes.
Apply Best Path Selection Algorithm
When a BGP router receives multiple routes for the same destination, it applies a multi-step decision process to choose the best one. The process evaluates attributes in order: weight, local preference, locally originated, AS path length, origin type, MED, eBGP over iBGP, IGP metric to next hop, and router ID. The winning route is installed in the routing table.
Propagate Chosen Routes
The router then advertises only the best route to its other BGP neighbors, unless configured otherwise. This prevents routing loops and reduces the size of routing tables. The route is propagated across the internet until all routers have a consistent view of the network.
Practical Mini-Lesson
BGP is a protocol that you will likely encounter if you work with networks that connect to the internet or to other organizations. To understand BGP in practice, you need to know the difference between external BGP and internal BGP. eBGP is used between routers in different autonomous systems, such as between a company and its ISP. iBGP is used between routers within the same AS. A key rule of iBGP is that routes learned from one iBGP neighbor are not advertised to another iBGP neighbor. This is the split horizon rule. To overcome this, you must configure a full mesh of iBGP connections or use route reflectors.
When configuring BGP on a router, you define the local AS number and specify the neighbors. Each neighbor is identified by its IP address and remote AS number. For eBGP, the remote AS number is different from the local one. For iBGP, it is the same. You can also set policies using route maps that modify attributes. For example, you might set a higher local preference for routes learned from a preferred ISP so that traffic uses that link when possible.
A common practical task is BGP route filtering. Without filters, your router might accept routes from a neighbor and then advertise them to other neighbors, potentially becoming a transit AS. To prevent this, you can apply prefix lists to control which routes are accepted or advertised. For instance, you might only accept default route from an ISP and not the full internet routing table.
BGP troubleshooting is a critical skill. Common issues include the session being stuck in the active state, which usually indicates a TCP connection problem such as a firewall blocking port 179 or an IP address mismatch. Another issue is that a route is not appearing in the routing table even though the BGP session is up. This can happen if the route is filtered, or if the next hop is unreachable. You can use commands like show ip bgp summary to check session status and show ip bgp to see the BGP table.
BGP also plays a role in modern cloud networking. For example, when you set up a site-to-site VPN between your on-premises network and AWS, you can configure dynamic routing using BGP. AWS uses BGP to exchange routes with your VPN gateway, enabling automatic failover if one VPN tunnel goes down. Understanding BGP allows you to design resilient hybrid cloud architectures.
Performance considerations include the size of the BGP table. The global BGP table currently has over 900,000 routes. Routers need sufficient memory to store this table. Some enterprises use default routes instead of full tables to reduce memory usage. Security considerations include using MD5 authentication for BGP sessions and implementing prefix filtering to prevent hijacking. By mastering these practical aspects, you will be ready to handle BGP in real networks and in certification exams.
Memory Tip
To remember the BGP best path selection order, use the acronym WLLAOMIER. Weight, Local preference, Locally originated, AS path, Origin, MED, eBGP vs iBGP, IGP metric to next hop, Router ID.
Covered in These Exams
Current Exam Context
Current exam versions that test this topic — use these objectives when studying.
Related Glossary Terms
802.1Q is the networking standard that allows multiple virtual LANs (VLANs) to share a single physical network link by tagging Ethernet frames with VLAN identification information.
802.1X is a network access control standard that authenticates devices before they are allowed to connect to a wired or wireless network.
An A record is a DNS record that maps a domain name to the IPv4 address of the server hosting that domain.
5G is the fifth generation of cellular network technology, designed to deliver faster speeds, lower latency, and support for many more connected devices than previous generations.
Two-factor authentication (2FA) is a security method that requires two different types of proof before granting access to an account or system.
Frequently Asked Questions
What is the main difference between BGP and OSPF?
OSPF is an interior gateway protocol used within a single network (AS) to find the shortest path based on cost. BGP is an exterior gateway protocol used between different networks (ASes) and makes decisions based on policies and path attributes, not just speed.
Why does BGP use TCP instead of UDP?
BGP requires reliable delivery of routing updates because incorrect information could cause major internet disruptions. TCP guarantees that messages arrive in order and without loss, which is essential for maintaining a correct routing table.
What is an autonomous system number?
An autonomous system number is a unique identifier assigned to a network or group of networks under a single administrative control. It is used in BGP to identify the origin of routes and to prevent routing loops.
What is the BGP path selection attribute that is checked first?
The first attribute checked is weight, which is a Cisco proprietary attribute set locally on the router. If the weight is not set, the next attribute, local preference, is evaluated.
Can BGP be used inside a single organization?
Yes, internal BGP (iBGP) is used within a single organization to distribute routes between routers. However, iBGP requires either a full mesh of connections or the use of route reflectors to work correctly.
What is BGP hijacking?
BGP hijacking occurs when a malicious or misconfigured router announces IP prefixes that it does not own, causing traffic to be redirected to the wrong network. This can be used for interception or disruption.
How does BGP handle route loops?
BGP uses the AS path attribute to prevent loops. When a router receives a route, it checks if its own AS number is already in the AS path. If it is, the route is discarded to avoid a loop.
Is BGP required for the CCNA exam?
Yes, BGP is included in the CCNA exam syllabus under the IP connectivity domain. You need to understand basic BGP concepts, states, and attributes, but not advanced configuration.
Summary
Border Gateway Protocol is the fundamental routing protocol that connects the internet's many autonomous systems together. Unlike interior protocols that focus on speed or distance, BGP is a policy-driven path-vector protocol that allows network operators to control exactly how traffic flows between their network and the outside world. It operates over TCP port 179, exchanges routing updates using messages like open, update, and keepalive, and selects the best path using a multi-attribute decision process.
For certification exams, you must understand the difference between eBGP and iBGP, the BGP states, the key attributes such as AS path and local preference, and the order of the best path selection algorithm. Common exam traps involve the priority of attributes, where learners mistakenly assume AS path length is the first criteria. BGP is tested on the CCNA, CCNP, and Network+ exams, often through scenario questions about multi-homing, failover, and route selection.
In real-world IT work, BGP is essential for network engineers, cloud architects, and security professionals who need to maintain reliable, secure, and policy-compliant internet connectivity. Mastering BGP will give you a deep understanding of how the internet really works and prepare you for advanced networking roles.