BGP Attributes and Path Selection
Lesson Contents
Attributes
o Weight
o Local Preference
o Originate
o AS path length
o Origin code
o MED
o eBGP path over iBGP path
o Shortest IGP path to BGP next hop
o Oldest Path
o Router ID
o Neighbor IP address
Path Selection
BGP (Border Gateway Protocol) routers usually receive multiple paths to the
same destination. Like how our IGPs (RIP, EIGRP, OSPF) work, we need to
select the best path to each destination.
IGPs select the path with the lowest metric. For example:
RIP selects the path with the lowest hop count.
OSPF selects the path with the lowest cost.
EIGRP selects the path with the highest bandwidth and lowest delay
(unless you change the K values).
BGP however, selects the best path based on a list of attributes. On the
Internet, it’s more important that you have granular control over how you
forward your traffic and to which autonomous systems instead of just going
for the shortest path based on a metric.
Let’s look at a quick example. Below I have the output of the BGP table of
a looking glass server:
oute-views.optus.net.au>show ip bgp
BGP table version is 781755060, local router ID is 203.202.125.6
Status codes: s suppressed, d damped, h history, * valid, > best, i -
internal,
r RIB-failure, S Stale, m multipath, b backup-path, x best-
external
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
* 1.0.0.0/24 203.202.143.34 0 7474 4826
13335 i
* 192.65.89.161 1 0 7474 4826
13335 i
* 202.139.124.130 1 0 7474 4826
13335 i
* 203.13.132.7 10 0 7474 4826
13335 i
*> 203.202.143.33 0 7474 4826
13335 i
This BGP router has 5 paths for network 1.0.0.0/24. Look at the > symbol at
the bottom left. The > symbol means that BGP has selected this path as
the best path. This path will be installed in the routing table.
Out of all those 5 paths, why did BGP select this path as the best path?
Attributes
This path was selected based on the following attributes:
Priority Attribute
1 Weight
2 Local Preference
3 Originate
4 AS path length
5 Origin code
6 MED
7 eBGP path over iBGP path
8 Shortest IGP path to BGP next hop
9 Oldest path
10 Router ID
11 Neighbor IP address
Let me give you a quick overview of each attribute. We will cover these in
other lessons in detail.
Weight
Prefer the path with the highest weight. This is a value that is local to the
router and it’s Cisco proprietary. The default value is 0 for all routes that are
not originated by the local router. You can learn how it works in the BGP
weight attribute lesson.
Local Preference
The local preference is used within an autonomous system and exchanged
between iBGP routers. We prefer the path with the highest local
preference. The default value is 100. To learn more, take a look at the BGP
local preference attribute lesson.
Originate
Prefer the path that the local router originated. In the BGP table, you will
see next hop 0.0.0.0. You can get a path in the BGP table through the BGP
network command, aggregation, or redistribution. A BGP router will prefer
routes that it installed into BGP itself over a route that another router
installed in BGP.
AS path length
Prefer the path with the shortest AS path length. For example, AS path 1 2
3 is preferred over AS path 1 2 3 4 5. You can learn more about AS path
length here.
Origin code
Prefer the lowest origin code. There are three origin codes:
IGP
EGP
INCOMPLETE
IGP is lower than EGP and EGP is lower than INCOMPLETE. You can learn how
it works in the origin code lesson.
MED
Prefer the path with the lowest MED. The MED is exchanged between
autonomous systems. For a detailed explanation, take a look at the MED
lesson.
eBGP path over iBGP path
Prefer eBGP (external BGP) over iBGP (internal BGP) paths.
Shortest IGP path to BGP next hop
Prefer the path within the autonomous system with the lowest IGP
metric to the BGP next hop.
Oldest Path
Prefer the path that we received first, in other words, the oldest path.
Router ID
Prefer the path with the lowest BGP neighbor router ID. The router ID is
based on the highest IP address. If you have a loopback interface, then the IP
address on the loopback will be used. The router ID can also be manually
configured.
Neighbor IP address
Prefer the path with the lowest neighbor IP address. If you have two eBGP
routers and two links in between then the router ID will be the same. In this
case, the neighbor IP address is the tiebreaker.
Path Selection
When BGP has multiple paths to a destination they are stored in the BGP
table. All paths are in the BGP table but only one gets installed in the routing
table.
Which path do we select? We start at the top of the list with BGP attributes
and work our way to the bottom:
1. We start with weight because it’s at the top of the BGP attributes list.
We now have two options:
1. If one path has a better weight then we select this path as the
best path.
2. If the weight is equal, we move down to the next attribute.
2. The next attribute is local preference. Once again, we have two
options:
1. If one path has a better local preference then we select this path
as the best path.
2. If the local preference is equal, we move down to the next
attribute.
3. We work our way down this attribute list until we have a tiebreaker to
select the best path. If all paths have the same BGP attributes, then we
end up with the neighbor IP address.
There are some exceptions to the BGP path selection process when you use
(advanced) BGP features like confederations, route reflectors, or multipath.
Cisco has a detailed list with the BGP best path selection algorithm.
I hope this lesson has been useful to understand how BGP selects the best
path.
How to Configure BGP Weight
Attribute
Weight is a Cisco proprietary BGP attribute that can be used to select a
certain path. Here’s what you need to know about weight:
Weight is the first BGP attribute in the list.
Cisco proprietary so you won’t find it on other vendor routers.
Weight is not exchanged between BGP routers.
Weight is only local on the router.
The path with the highest weight is preferred.
Let me give you an example of BGP weight:
R1 in AS 1 can reach AS 3 through AS 2 or AS 4. If we want to ensure AS 2 is
always used as the best path, you can change the weight. In my example,
the weight for the path to AS 2 is set to 500 and higher than the weight of
400 for AS 4. Let’s see what this looks like on real Cisco routers. This is the
topology that I will use:
Above, we have a simple scenario with two autonomous systems. R2 and R3
both have network 2.2.2.0/24 configured on their loopback0 interface, and I’ll
advertise that in BGP.
R1(config)#router bgp 1
R1(config-router)#bgp router-id 1.1.1.1
R1(config-router)#neighbor 192.168.12.2 remote-as 2
R1(config-router)#neighbor 192.168.13.3 remote-as 2
R2(config)#router bgp 2
R2(config-router)#bgp router-id 2.2.2.2
R2(config-router)#neighbor 192.168.12.1 remote-as 1
R2(config-router)#neighbor 192.168.23.3 remote-as 2
R2(config-router)#network 2.2.2.0 mask 255.255.255.0
R3(config)#router bgp 2
R3(config-router)#bgp router-id 3.3.3.3
R3(config-router)#neighbor 192.168.13.1 remote-as 1
R3(config-router)#neighbor 192.168.23.2 remote-as 2
R3(config-router)#network 2.2.2.0 mask 255.255.255.0
Above you’ll find the configuration for BGP. I configured the manual router ID
for a reason. R2 and R3 have the same IP address on the loopback interface,
which means they would get the same router ID, and they would be unable to
form a BGP neighbor adjacency. Let’s take a detailed look at R1:
R1#show ip bgp
BGP table version is 2, local router ID is 192.168.13.1
Status codes: s suppressed, d damped, h history, * valid, > best, i -
internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 2.2.2.0/24 192.168.12.2 0 0 2 i
* 192.168.13.3 0 0 2 i
Router R1 decided to use 192.168.12.2 as the next hop. All the BGP
attributes are the same, so it came down to the router ID to select a winner.
The default weight for a prefix that the router originates is 32768. You can
verify this by taking a look at prefix 2.2.2.0/24 in the BGP table on R2 or R3.
Now let’s change this behavior using the weight attribute…
R1(config)#router bgp 1
R1(config-router)#neighbor 192.168.13.3 weight 500
You can configure weight per neighbor using the weight command. All
prefixes from this neighbor will have a weight of 500.
BGP Local Preference Attribute
BGP attribute local preference is the second BGP attribute and it can be used
to choose the exit path for an autonomous system. Here are the details:
Local preference is the second BGP attribute.
You can use local preference to choose the outbound external BGP
path.
Local preference is sent to all internal BGP routers in your
autonomous system.
Not exchanged between external BGP routers.
Local preference is a well-known and discretionary BGP attribute.
The default value is 100.
The path with the highest local preference is preferred
Let me show you an example:
You can use local preference to configure your autonomous system to select
a certain exit point. Instead of configuring weight on each router, you can use
local preference because it is exchanged on all internal BGP routers. By
increasing the local preference to 800, we can make AS 1 send all traffic
toward AS 2.
A well-known discretionary BGP attribute must be recognized by all BGP
routers per RFC, but its presence in a BGP update is optional.
Configuration
Now let me show you how to configure local preference. Here is the topology
that we will use:
In the picture above, we have two autonomous systems. R1 will advertise
network 1.1.1.0/24 towards AS 2, and R4 will have to choose when it wants to
reach this network. It can go through router R2 or R3. We’ll see how local
preference influence this. Here’s the default BGP configuration of R1:
R1(config)#router bgp 1
R1(config-router)#neighbor 192.168.12.2 remote-as 2
R1(config-router)#neighbor 192.168.13.3 remote-as 2
R1(config-router)#network 1.1.1.0 mask 255.255.255.0
Let’s configure AS 2 with OSPF:
R2(config)#interface loopback 0
R2(config-if)#ip address 2.2.2.2 255.255.255.0
R2(config)#router ospf 1
R2(config-router)#network 192.168.24.0 0.0.0.255 area 0
R2(config-router)#network 2.2.2.0 0.0.0.255 area 0
R3(config)#interface loopback 0
R3(config-if)#ip address 3.3.3.3 255.255.255.0
R3(config)#router ospf 1
R3(config-router)#network 192.168.34.0 0.0.0.255 area 0
R3(config-router)#network 3.3.3.0 0.0.0.255 area 0
R4(config)#interface loopback 0
R4(config-if)#ip address 4.4.4.4 255.255.255.0
R4(config)#router ospf 1
R4(config-router)#network 192.168.24.0 0.0.0.255 area 0
R4(config-router)#network 192.168.34.0 0.0.0.255 area 0
R4(config-router)#network 4.4.4.0 0.0.0.255 area 0
Now we can configure IBGP within AS 2:
R2(config)#router bgp 2
R2(config-router)#neighbor 192.168.12.1 remote-as 1
R2(config-router)#neighbor 3.3.3.3 remote-as 2
R2(config-router)#neighbor 3.3.3.3 update-source loopback0
R2(config-router)#neighbor 4.4.4.4 remote-as 2
R2(config-router)#neighbor 4.4.4.4 update-source loopback0
R2(config-router)#neighbor 4.4.4.4 next-hop-self
R3(config)#router bgp 2
R3(config-router)#neighbor 192.168.13.1 remote-as 1
R3(config-router)#neighbor 2.2.2.2 remote-as 2
R3(config-router)#neighbor 2.2.2.2 update-source loopback0
R3(config-router)#neighbor 4.4.4.4 remote-as 2
R3(config-router)#neighbor 4.4.4.4 update-source loopback0
R3(config-router)#neighbor 4.4.4.4 next-hop-self
R4(config)#router bgp 2
R4(config-router)#neighbor 2.2.2.2 remote-as 2
R4(config-router)#neighbor 2.2.2.2 update-source loopback 0
R4(config-router)#neighbor 3.3.3.3 remote-as 2
R4(config-router)#neighbor 3.3.3.3 update-source loopback 0
And above, you can see the BGP configurations.
Now let’s find out what path R4 will use to reach network 1.1.1.0/24:
BGP Attributes
The Border Gateway Protocol (BGP) is responsible for finding the best route for data
transmission between two endpoints connected across the internet. In this article,
we dive deep into its inner workings to answer a common network engineering
question: How do BGP attributes work? Before we launch into an explanation, let’s
first review a few fundamental concepts that we’ll reference throughout this article.
Introduction
The Border Gateway Protocol (BGP) is responsible for finding the best route for data
transmission between two endpoints connected across the internet. In this article,
we dive deep into its inner workings to answer a common network engineering
question: How do BGP attributes work?
Before we launch into an explanation, let’s first review a few fundamental concepts
that we’ll reference throughout this article.
Definitions for Context
Autonomous System: An Autonomous System (AS) represents a set of IP
prefixes that belong to a network and are managed by a single organization.
Each AS is assigned an Autonomous System Number (ASN), which is unique to
the network.
Internal and External BGP: Border Gateway Protocol (BGP) is the protocol
that runs the internet. It is a routing protocol that exchanges routing and
reachability information between AS on the internet. Small enterprises run
BGP only on the edge where they are connected to their ISPs (one or more
ISPs and each ISP is connected to at least one router for redundancy
purposes). Large enterprises utilize internal BGPs to facilitate communication
within a single AS.
Connection to peer AS: An enterprise or any given organization that owns
an AS can be connected to one or more upstreams. To each upstream, there
can be one or more connections and these connections can be all to the same
device or spread among multiple devices.
BGP Attribute Categories
There are four categories of BGP attributes:
1. Well-known mandatory:Recognized by all BGP peers, passed to all peers,
and present in all Update messages. Well-known mandatory attributes
include:- Next-hop- Origin- AS PATH
2. Well-known discretionary:Recognized by all routers, passed to all peers,
and optionally included in the Update message. Well-known discretionary
attributes include:- Local Preference- Atomic Aggregate
3. Optional transitive:Possibly recognized by BGP routers and passed to BGP
peers. Optional transitive attributes are marked as partial when not
recognized. Optional transitive attributes include:- Aggregator- Community
4. Optional non-transitive:Possibly recognized by BGP routers but not passed
to peers. Optional non-transitive attributes include:- Multi-exit discriminator
(MED)- Originator ID- Cluster-ID
Each networking equipment vendor can create their own BGP attributes, which are
understood by their routers. However, attributes that are not understood go ignored.
That said, it is unlikely that a network will be running BGP without Cisco routers
(there might be enterprises that do not use Cisco, but their number is very small).
While on the topic of vendor-specific attributes, it’s worth mentioning an important
but proprietary Cisco attribute which we will reference later in this article: Weight.
Weight has local significance for preferred route selection and a higher value is
favored.
SYNTHETIC MONITORING
Are you getting enough from your synthetic monitoring?
Try out the industry’s most feature-rich synthetics solution
Try Catchpoint
BGP Update Message
An Update message is used to transfer routing information between BGP neighbours,
making the advertisement and withdrawal of routes possible. The following are the
most important BGP fields for Update messages:
Total Path Attribute Length: Indicates the total length of the Path
Attributes field.
Path Attributes: Follows the format of and contains the following two
subfields:
Attribute Flags: Defines if the attribute is well-known, optional, transitive, or
non-transitive. States if the information from the Update is partial or
complete.
Attribute Type Code: Identifies the attribute (for instance, the ORIGIN
attribute has the type code 1).
BGP Best Path Selection Algorithm
To decide which route is the best, each BGP router has a “best path selection”
algorithm, where the information from two similar paths are compared. This is
because it is not unusual for a BGP speaker to receive the same route from multiple
peers. In fact, this is quite normal when you have multiple upstreams or peers.
Before we cover how the BGP best path selection algorithm works, however, it’s
important to know that not all of the received BGP routes are candidates for being
selected as the best route. There are many reasons for this, a common one being
that the next-hop advertised as an attribute for the route is inaccessible.
Now, let’s take a look at the factors that govern selecting a best route candidate
(and the order they are considered in) using the BGP selection algorithm on a Cisco
router:
1. A path with the highest Weight attribute is preferred (other vendors ignore
this attribute).
2. A path with the highest “local preference” is preferred (usually set to 100).
3. A path that was locally originated using “network” or “aggregate” command
or using redistribution from IGP is preferred.
4. A path with the shortest AS Path is preferred (skippable via router
configuration).
5. A path with the lowest origin type is preferred. Origin types are preferred in
this order:- IGP- EGP- Incomplete
6. A path with the lowest MED is preferred. By default, the MED is compared only
if the neighbour AS is the same for the paths that are compared (this is
configurable). There are multiple commands related to how and when to treat
the MED value of the paths, which, due to its complexity, is outside the scope
of this article.
7. A path that is an External BGP path is preferred (versus internal).
8. A path with the lowest IGP metric for BGP next-hop is preferred. At this point,
if multipath is configured, the Router installs the routes. If not, the algorithm
continues to the next step.
9. If both routes are external, the oldest route is preferred. This step is skipped if
the BGP is configured to compare the router-ID or the paths have the same
router-ID.
10. A path with the lowest router ID is preferred. The router-ID can be manually
set or it can be set automatically using the highest IP address configured (first
the loopback interfaces are considered and then the physical interfaces).
11. A path with the shortest cluster list length is preferred. This step is applicable
only in a route reflector environment. If this is not the case, this step is
skipped.
12. A path from the lowest neighbour address is preferred. At this point, at least
one route should be selected as the best route (or multiple, after step 8).
BGP OBSERVABILITY
Ready to dive deeper into BGP?
Learn about the vulnerabilities of BGP, and the best monitoring practices to catch
and mitigate prefix hijacks and route leaks.
Learn more
Examples
Let’s look at some examples where a router compares various BGP attributes to
select the best route.
Weight
In the scenario illustrated below, R1 sets the Weight value for prefixes coming from
R12 (from AS 12 - 200) and leaves the attribute to the default value for the prefixes
coming from R11 from AS 11.
When R1 runs the best path selection algorithm (because it is a Cisco device), it
compares the Weight value locally set for the prefixes. If one of the paths has a
higher value than the others, it is selected and the algorithm stops.
Considering the following example, R1 should prefer the path received from R12:
Router Input
R1#sh ip bgp 10.10.10.0
BGP routing table entry for 10.10.10.0/24, version 2
Paths: (2 available, best #1, table default)
Advertised to update-groups:
2
Refresh Epoch 2
12 111
1.1.2.2 from 1.1.2.2 (1.1.4.1)
Origin IGP, localpref 100, weight 200, valid, external, best
rx pathid: 0, tx pathid: 0x0
Refresh Epoch 2
11 111
1.1.1.2 from 1.1.1.2 (1.1.3.1)
Origin IGP, localpref 100, valid, external
rx pathid: 0, tx pathid: 0
R1#
Local Preference
Local preference is a well-known discretionary attribute. In other words, it is
recognized by all the routers if it is present in the update.
In this scenario, R1 sets the Weight to 200 for the prefixes from every BGP peer. If
the Weight attribute is equal, then the best path selection algorithm compares the
Local preference attribute value.
Considering the following scenario:
R1 chooses the path from R11 because the Local preference for the routes coming
from R11 is set to 110, which is higher than the default value, 100, set for the routes
coming from R12.
Router Input
R1#sh ip bgp 10.10.10.0
BGP routing table entry for 10.10.10.0/24, version 2
Paths: (2 available, best #1, table default)
Advertised to update-groups:
3
Refresh Epoch 2
11 111
1.1.1.2 from 1.1.1.2 (1.1.3.1)
Origin IGP, localpref 110, weight 200, valid, external, best
rx pathid: 0, tx pathid: 0x0
Refresh Epoch 2
12 111
1.1.2.2 from 1.1.2.2 (1.1.4.1)
Origin IGP, localpref 100, weight 200, valid, external
rx pathid: 0, tx pathid: 0
R1#
AS Path
The AS_PATH attribute is a well-known mandatory attribute and represents the list of
the AS the prefix has crossed. Each AS is added in front of the current AS PATH.
In the following example, the route received by R1 from R11 has the AS_PATH 11
111 and the route received from R12 has the AS_PATH 12 22 111.
AS_PATH is a mandatory attribute evaluated by BGP when selecting a route.
Because a shorter AS_PATH is better than a longer AS_PATH, if all the previous steps
of the algorithm could not select the best route, the route with the shortest AS_PATH
is selected as the best route.
Router Input
R1#sh ip bgp 10.10.10.0/24
BGP routing table entry for 10.10.10.0/24, version 2
Paths: (2 available, best #2, table default)
Advertised to update-groups:
4
Refresh Epoch 4
12 22 111
1.1.2.2 from 1.1.2.2 (1.1.4.1)
Origin IGP, localpref 110, weight 200, valid, external
rx pathid: 0, tx pathid: 0
Refresh Epoch 3
11 111
1.1.1.2 from 1.1.1.2 (1.1.3.1)
Origin IGP, localpref 110, weight 200, valid, external, best
rx pathid: 0, tx pathid: 0x0
R1#
Origin
At step 5 of the best path selection algorithm, a router compares the value of the
Origin attribute. The Origin attribute has three possible values (or codes):
i - IGP
e - EGP
? - incomplete
In the following scenario, R1 sees the routes from R11 with an origin of “IGP” and the
routes from R12 with an origin of “incomplete.” Because all the previous steps of the
best path selection algorithm could not select the best path (due to the fact that all
the values were equal), the Origin values must be compared.
Since Origin IGP is better than Origin Incomplete, the route from R11 is chosen as
the best route.
Router Input
R1#sh ip bgp 10.10.10.0/24
BGP routing table entry for 10.10.10.0/24, version 2
Paths: (2 available, best #2, table default)
Advertised to update-groups:
4
Refresh Epoch 3
12 111
1.1.2.2 from 1.1.2.2 (1.1.4.1)
Origin incomplete, localpref 110, weight 200, valid, external
rx pathid: 0, tx pathid: 0
Refresh Epoch 2
11 111
1.1.1.2 from 1.1.1.2 (1.1.3.1)
Origin IGP, localpref 110, weight 200, valid, external, best
rx pathid: 0, tx pathid: 0x0
Multi-exit Discriminator (MED)
MED is an optional non-transitive BGP attribute. It is exchanged between the AS,
propagated to all the routers in the AS, but not advertised to any other AS.
In the following scenario, R111 advertises the route to R11 and R12 routers with
different MED values. R11 and R12 both advertise the route to R1, which has to run
the BGP best path selection algorithm.
Considering that all the previous steps could not be used to select the best path,
MED is evaluated and the path with the lowest MED value is chosen.
From R1, it can be seen that the routes received from R11 and R12 are keeping the
MED values set by R111 and the route chosen is the one with the lowest MED.
Router Input
R1#sh ip bgp 10.10.10.0/24
BGP routing table entry for 10.10.10.0/24, version 7
Paths: (2 available, best #1, table default)
Not advertised to any peer
Refresh Epoch 1
111
1.1.1.2 from 1.1.1.2 (1.1.3.1)
Origin IGP, metric 11, localpref 110, weight 200, valid,
internal, best
rx pathid: 0, tx pathid: 0x0
Refresh Epoch 1
111
1.1.2.2 from 1.1.2.2 (1.1.5.1)
Origin IGP, metric 12, localpref 110, weight 200, valid, internal
rx pathid: 0, tx pathid: 0
R1#
Community
A BGP community is an optional transitive BGP attribute that can traverse from AS to
AS. The BGP communities can be set, removed, or modified selectively (e.g., you can
add additional communities). BGP communities can be used to tag routes with the
purpose of enforcing routing policies. To give an example, when a route received has
a specific BGP community attached to it, the router can perform various operations
on other BGP attributes of that route.
There are four well known BGP communities:
Internet: Prefix can be advertised to all BGP neighbors.
No-Advertise: Prefix should not be advertised to any BGP neighbors.
No-Export: Prefix should not be advertised to any External BGP neighbors.
Local-AS: Prefix should not be advertised outside of the sub-AS.
While a BGP community is not a BGP attribute that is evaluated in order to select the
best route, it allows the operator to influence the result of the BGP best path
selection algorithm.
In the following scenario, R11 and R12 set a specific Local Preference value to
routes, based on the community that is attached when they are sent by R111. R1
receives the same route twice and must run the BGP best path selection algorithm.
So now, R1 must choose between a path with LOCAL_PREF of 110 and a path with
LOCAL_PREF of 105.
Router Input
R1#sh ip bgp 10.10.10.0/24
BGP routing table entry for 10.10.10.0/24, version 12
Paths: (2 available, best #1, table default)
Not advertised to any peer
Refresh Epoch 2
111
1.1.1.2 from 1.1.1.2 (1.1.3.1)
Origin IGP, metric 0, localpref 110, valid, internal, best
rx pathid: 0, tx pathid: 0x0
Refresh Epoch 2
111
1.1.2.2 from 1.1.2.2 (1.1.5.1)
Origin IGP, metric 0, localpref 105, valid, internal
rx pathid: 0, tx pathid: 0
R1#
As mentioned, the algorithm does not evaluate the community. However it evaluates
one of the attributes that was changed due to matching a specific community.
Summary
Now you know how a router evaluates the BGP attributes found in the UPDATE
messages to select the best path to be installed in the routing table. Although
vendors can define their own BGP attribution methods, most routers are made by
Cisco and thus use Cisco’s best path selection algorithm.
What is BGP?
Border Gateway Protocol (BGP) is the Internet's postal service. When
someone places a letter in a mailbox, the Postal Service processes it and
determines the most efficient way to send it to its intended destination.
When someone sends data over the Internet, BGP is in charge of
analysing all of the possible paths for the data to take and selecting the
best one, which frequently involves hopping between autonomous
systems. BGP is the protocol that allows data to be routed across the
Internet. For example, the border gateway protocol is the protocol that
allows a user in Singapore to communicate swiftly and efficiently with
origin servers in Argentina when they visit a website.
The protocol can link any autonomous system's internetwork together
utilising any topology. The sole need is that each autonomous system
should have at least one BGP-capable router that is connected to the
BGP router of at least one other autonomous system. The primary
purpose of BGP is to communicate network reachability information with
other BGP systems. Based on the information transmitted between BGP
routers, the Border Gateway Protocol creates an autonomous systems
graph.
Crack your next tech interview with confidence!
Take a free mock interview, get instant⚡️feedback and recommendation💡
Attempt Now
Events|Powered By
Software Dev
Data Science
All Events
Java Vs Python
Starts on: 08:00 PM, 25 January 2023 (IST)
10574 Registered
Know More
Register Now
System design of Payment Gateway Apps
Starts on: 05:00 PM, 29 January 2023 (IST)
496 Registered
Know More
Register Now
Learn how to collaborate with Millions of Coders using Github
Starts on: 07:00 PM, 31 January 2023 (IST)
3004 Registered
Know More
Register Now
Become a MAANG Engineer
Starts on: 08:00 PM, 7 February 2023 (IST)
36 Registered
Know More
Register Now
View All
BGP Interview Questions for Freshers
1. What are the characteristics of the Border Gateway
Protocol (BGP)?
Following are the characteristics of the Border Gateway Protocol:
Configuration of Inter-Autonomous Systems: The Border Gateway
Protocol's primary function is to provide communication between
two autonomous systems.
Next-Hop Paradigm is supported by the Border Gateway Protocol.
Within the autonomous system, there is coordination among
several BGP speakers.
Path Information: In addition to the reachable destination and next
destination pair, BGP advertisements offer path information.
In the routing-decision algorithm of BGP, numerous attributes are
used.
External neighbours between various autonomous systems are
communicated via eBGP.
Internal neighbours inside the same autonomous system use iBGP.
It uses weight to alter the outward traffic routing from a single
locally configured router.
Policy Support: The Border Gateway Protocol can implement
policies that the administrator can configure. A router running BGP,
for example, can be set to discriminate between routes known
within the autonomous system and routes known from outside the
autonomous system.
TCP (Transmission Control Protocol) is used in conjunction with
Border Gateway Protocol.
Border Gateway Protocol helps networks save bandwidth.
Classless Inter-Domain Routing (CIDR) is supported by BGP.
Security is also supported by BGP.
2. What port number is used by the border gateway
protocol?
The Border Gateway Protocol uses the Transmission Control Protocol
(TCP) port number 179.
3. Is it possible for routers on different subnets to
become BGP neighbours?
BGP is frequently set up between two routers that are directly
connected and belong to distinct autonomous systems. BGP routers don't
require their neighbours to be on the same subnet. Instead, they employ
a TCP connection between the routers to send and receive BGP
messages, allowing neighbouring routers to be on the same or distinct
subnets.
You can download a PDF version of Bgp Interview Questions.
Download PDF
4. Is it possible to run two BGP processes on the same
router?
No, you can't have two BGP processes running on the same router. This
is because BGP is an Exterior Gateway Protocol.
5. What do you understand by Routing Information
Protocol (RIP) in the context of networking?
The Routing Information Protocol (RIP) is a dynamic routing protocol
that finds the optimum path between the source and destination
networks by using hop count as a routing metric. It is a distance-vector
routing protocol with an AD value of 120 that operates at the OSI
application layer. The RIP protocol uses port 520. The number of routers
between the source and destination networks is referred to as the hop
count. The path with the fewest hops is deemed the best route to a
network and is thus entered into the routing table. The number of hops
allowed in a path between source and destination is limited by RIP, which
eliminates routing loops. The maximum number of hops allowed by RIP is
15, and a hop count of 16 is considered unreachable by the network.
Following are the features of Routing Information Protocol (RIP):
Network updates are exchanged on a regular basis.
Routing information (updates) are always broadcast.
Routing tables in their entirety are sent in updates.
Routing information received from nearby routers is always trusted
by routers. This is also known as rumour routing.
6. Differentiate between internal Border Gateway
Protocol (iBGP) and external Border Gateway Protocol
(eBGP).
internal Border Gateway Protocol(iBGP): Inside autonomous
systems, IBGP is used. Its purpose is to feed data to your internal
routers. For prefix learning, all devices in the same autonomous
system must form a full mesh topology or use either Route
reflectors or Confederation.
external Border Gateway Protocol (eBGP): It is employed
between autonomous systems. It's used and deployed at the edge
or border router, which connects two or more autonomous systems
together. It is the protocol that allows networks from various
organisations or the Internet to communicate with one another.
The following table lists the differences between the internal Border
Gateway Protocol and the external Border Gateway Protocol:
internal Border Gateway external Border Gateway
Protocol (iBGP) Protocol (eBGP)
It connects two BGP routers in a It connects two BGP routers in
single autonomous system. separate independent systems.
Its Administrative Distance is set to
Its Administrative Distance is set to
200 by default. 20 by default.
IBGP routes obtained from an IBGP EBGP routes can be published to
peer can be broadcast to an EBGP EBGP and IBGP peers when received
peer but not to another IBGP peer. from an EBGP peer.
It necessitates the use of full meshIt does not necessitate a complete
topology. mesh topology.
It's used between corporations or
Within the same corporation, it's
between corporations and Internet
used.
service providers.
For loop prevention, it employs BGP It prevents loops by using an AS
Split Horizon. path.
TTL (Time To Live) = 255 is the TTL (Time To Live) = 1 is the default
default setting for peers. setting for peers.
Attributes such as local preference
Attributes such as local preference
are not communicated between
are exchanged between IBGP peers.
EBGP peers.
The next hop remains constant When a route is announced to an
when a route is advertised to an EBGP peer, the local router becomes
IBGP peer. the next hop.
7. What do you understand about split horizon in the
context of BGP? Explain with an example.
Split Horizon: The split horizon is a method employed by distance
vector protocols to prevent network routing loops. The underlying
premise is straightforward: never send routing information back in the
same direction it came from. It is necessary to have a split-horizon
because distance vector protocols like Routing Information Protocol (RIP)
are prone to routing loops, which occur when a data packet is caught in
an unending loop and routed through the same routers over and over
again. Split horizon is frequently used in protocols to avoid loops.
Different strategies are used to prevent packet looping in other
protocols, such as Open Shortest Path First.
When split horizon is enabled, a router is prevented from advertising a
route back to the router from whence it learnt it. To put it another way, if
a router receives routing information from another router, the first router
will not broadcast it back to the second router, preventing routing loops.
Example: An example of three routers used to forward packets between
networks is shown in the diagram below. The R3 router transmits routing
information about the 10.0.0.0/16 network to the R2 router in this simple
architecture. This information is received by the R2 router, which
modifies its routing table and broadcasts it to the R1 router. The R1
router modifies its routing database when it receives this information.
The modified routing information allows the R1 router to send packets to
the 10.0.0.0/16 network via the R2 and R3 routers. The R1 router will not
be able to advertise this network route back to the R2 router if a split
horizon is enabled. If the R1 router does not have split-horizon enabled,
it will broadcast the route to the R2 router, which will update its routing
table to reflect the network route available through the R1 router.
The presence of the R1 route in the R2 routing database is not an issue
in typical operations because it is plainly a lot more expensive route than
a direct R2-to-R3 connection. If the R2-to-R3 connection fails and the R2
router receives a packet from R1 destined for the 10.0.0.0/16 network,
the R2 router will return the packet to R1 because the router advertised
a functional network path. However, based on its own routing
information, the R1 router will just return the packet to the R2 router,
resulting in a routing loop that will continue until the packet dies. The R1
router will not advertise the network route to the R2 router if the split
horizon is enabled, preventing the routing loop.
8. What do you understand about poison reverse in the
context of BGP?
Poison Reverse: The Poison Reverse algorithm is a widely used
distance-vector routing algorithm. To solve the count-to-infinity problem,
poison reverse is used. To put it another way, poison reverse is the
inverse of the split horizon. Route advertisements that would be muted
by split horizon are instead advertised at a distance of infinity with
poison reverse. Poison reverse is a RIP (Routing Information Protocol)
technique. When path information becomes invalid, routers do not
instantly remove it from the routing database; instead, they broadcast a
hop-count of 16, which is an unreachable metric value. This increases
the size of the routing table but aids in the elimination of loops. It can
break any loop between neighbouring routers right away. The main
notion of poison reverse is to ensure that a path does not return to the
same node if the network's cost has changed.
9. What do you understand by peers in the context of
BGP? What is the purpose of BGP peer groups?
BGP peers are two routers that have established a link for exchanging
BGP information. Such BGP peers provide routing information via TCP-
based BGP sessions, which are dependable, connection-oriented, and
error-free protocols.
The above image shows a BGP peering session between two BGP routers.
We may utilise peer groups to simplify BGP configuration and reduce the
amount of updates BGP has to produce. We can create a peer group with
the neighbours and then apply all of our setups to it.
10. Is authentication possible with BGP? If yes, explain
how.
Yes. MD5 authentication is supported by BGP. BGP allows neighbours to
authenticate each other using MD5 and a shared password. It is set up
with the following command neighbour {ip-address | peer-group-
name} password password in BGP router setup mode. When
authentication is enabled, BGP verifies the source of each routing update
and authenticates every TCP segment from its peer. Authentication is
required by most ISPs for their EBGP peers.
Peering works only if both routers have the same password and are
configured for authentication. When a router has a password configured
for a neighbour but the neighbour router does not, the console displays a
message like this when the routers try to create a BGP session.
%TCP-6-BADAUTH: No MD5 digest from [peer's IP address]:11003 to
[local router's IP address]:179
Similarly, if the two routers are configured with different passwords, a
message like this will appear on the screen:
%TCP-6-BADAUTH: Invalid MD5 digest from [peer's IP address]:11004 to
[local router's IP address]:179
11. In BGP, what is the order of preference?
The order of preference in BGP differs depending on whether the
attributes are used for inbound or outbound updates.
The following is the order of preference for inbound updates:
1. Route-map
2. Filter-list
3. Prefix-list
4. distribute-list
The following is the order of preference for outgoing updates:
1. Filter-list
2. Route-map | unsuppress-map
3. Advertise-map (conditional-advertisement)
4. Prefix-list
5. distribute-list.
12. What are the different types of Timers present in
BGP?
Following are the different types of Timers present in BGP :
Keep Alive Timer : This is the heartbeat timer, in which a local
neighbour sends a BGP heart-beat packet to a remote neighbour at
regular intervals to check reachability and availability. This interval
is set to '30' seconds by default.
Hold down Timer : This is the amount of time that the local
neighbour must wait before declaring the remote neighbour
unavailable. This interval is set at "90" seconds by default, which is
'3' times the Keep-Alive Interval. In other words, if a local
neighbour misses three Keep-Alive packets in a row from a remote
neighbour, the local neighbour considers the remote neighbour
unavailable and changes the status of the neighbourship, as well
as removing all associated routes advertised by the neighbour from
the routing table/BGP table. Before and after the hold-down timer
expires, the BGP neighbour status changes. The hold down timer is
set to 90 seconds by default, and after that, the local neighbour
moves through various stages like 'idle,' 'connect,' and 'active.' The
status changes to 'Idle' at first, then to 'Connect' after 5 seconds,
and then to 'Active' after 10 seconds.
Advertisement Interval : The BGP Advertisement Interval is a
timer that determines how much time must pass between a route
being advertised and being removed from a BGP peer. For eBGP
peers, the default is 30 seconds, and for iBGP peers, it's 5 seconds.
This can be modified on a per-neighbor basis.
13. Is it possible to utilise BGP (Border Gateway Protocol)
instead of any IGP (Interior Gateway Protocol)?
No, we can't use BGP instead of any IGP because BGP connects different
autonomous systems, whereas IGP works inside autonomous systems.
14. What are the various BGP Neighbor Adjacency States?
Before any routing information is transmitted, BGP establishes a
neighbour adjacency with other routers, similar to OSPF (Open Shortest
Path First) or EIGRP (Enhanced Interior Gateway routing Protocol). BGP,
on the other hand, does not use broadcast or multicast for BGP
neighbour discovery; instead, neighbours are manually configured and
communicate over TCP/179.
Two BGP systems will go through a succession of BGP Neighbor
Adjacency States before becoming neighbours. They are as follows:
Idle - The router initialises BGP resources. Attempts to establish a
BGP incoming connection are rejected. The BGP protocol
establishes a TCP connection with the peer.
Connect - BGP waits for the three way handshake to finish. The
OPEN message is transmitted to the peer if it is successful, and
BGP shifts to the OpenSent state. If we are unsuccessful, we will
return to the Active state. If the ConnectRetry timeout expires,
however, BGP will continue in this condition, with the timer reset
and a new three way handshake launched.
Active - BGP returns to the Connect state after the ConnectRetry
timeout is reset.
OpenSent - BGP waits for an OPEN message from its peer before
sending it. BGP enters the OpenConfirm state after receiving a
message.
OpenConfirm - BGP waits for a peer to send a keepalive message.
BGP goes to the Established state if a response is received before
the timeout ends. Otherwise, BGP switches to Idle mode.
Established - Both peers exchange UPDATE messages once the
connection is established. If any of the UPDATE messages include
an error, the BGP peer will send a NOTIFICATION message and
enter the Idle state.
15. What are the different types of attributes present in
BGP?
Following are the different types of attributes present in bgp:
Well-known mandatory: All BGP peers recognise it, it is
forwarded to all peers, and it is present in all Update messages.
The following are some of the well-known mandatory attributes :
o Next-hop
o Origin
o AS PATH
Well-known discretionary: All routers recognise it, it's sent to all
peers, and it's optionally included in the Update message. The
following are some of the well-known discretionary attributes :
o Local Preference
o Atomic Aggregate
Optional transitive: It's possible that BGP routers will recognise it
and transmit it on to BGP peers. When optional transitive qualities
are not recognised, they are denoted as partial. The following are
examples of optional transitive attributes:
o Aggregator
o Community
Optional non-transitive: BGP routers may recognise it, but it is
not forwarded to peers. The following are some of the optional non-
transitive attributes :
o Multi-exit discriminator (MED)
o Originator ID
o Cluster-ID
16. Mention some of the well known BGP metric’s
attributes.
BGP path selection is based on the values of the following attributes:
Weight
Local Preference (highest local value will be preferred, default
value is 100)
Originate
AS path length
Origin code
Multi-Exit Discriminator (MED)
eBGP path over iBGP path
Shortest IGP path to BGP next hop
Oldest path
Router ID
Neighbor IP address.
17. What exactly do you mean by a route reflector in the
context of Border Gateway Protocol? Why is it necessary?
In BGP, a route reflector is a router which is capable of breaking the
internal Border Gateway Protocol (iBGP) loop avoidance rule. Under
certain settings, a route reflector can broadcast updates received from
an iBGP peer to another iBGP peer.
By breaking the criterion and designing iBGP networks that scale quickly
and cleanly, route reflectors are employed to eliminate the full mesh
requirement.
BGP Interview Questions for Experienced
18. Differentiate between Open Shortest Path First
(OSPF) and Border Gateway Protocol (BGP).
Open Shortest Path First (OSPF): Open shortest path first (OSPF) is a
link-state routing protocol that uses its own shortest path first (SPF)
algorithm to discover the optimum path between the source and
destination router. A link-state routing protocol employs the idea of
triggered updates, in which updates are only triggered when a change in
the learnt routing table is detected, as opposed to the distance-vector
routing protocol, in which the routing table is exchanged over a period of
time. Open shortest path first (OSPF) is an Interior Gateway Protocol
(IGP) that tries to move packets within a large autonomous system or
routing domain. It's a network layer protocol that uses AD value 110 and
runs on protocol number 89. OSPF employs the multicast address
224.0.0.5 for routine communication and 224.0.0.6 for updates to
designated routers (DRs) and backup designated routers (BDRs) (BDR).
Following are the differences between Border Gateway Protocol (BGP)
and Open Shortest Path First (OSPF):
Open Shortest Path First (OSPF) Border Gateway Protocol (BGP)
Open Shortest Path First is a fast
BGP is a slow concurrency protocol.
concurrency protocol.
OSPF is a network topology or design It uses a sort of mesh topology or
that is hierarchical. design.
Internal gateway protocol is another It is referred to as an external
name for it. gateway protocol.
OSPF is a simple protocol to set up. BGP implementation is challenging.
It connects to port 89. It works with port number 179.
The internet protocol is employed in Transmission control protocol is
OSPF. employed in this.
OSPF is a type of Link State. BGP is a Vector State type.
The Dijkstra algorithm is employed in The best path algorithm is
OSPF. employed in this case.
OSPF prioritises the quickest path
BGP prefers the best path.
over the shortest path.
19. Differentiate between hard reset and soft reset in the
context of BGP.
Following are the differences between hard reset and soft reset in the
context of BGP:
Basis Hard Reset Soft Reset
Goal There are two types of soft
resets:
1. Soft reset with Route
refresh: A soft reset with
The TCP session with the BGP
Route refresh allows BGP
neighbour is killed by Hard
peers to seek an update
Reset, and it must be
without destroying the
restarted. It terminates the TCP
neighbour relationship.
connection between the peers,
re-establishes the connection
2. Soft-reconfiguration:
with a BGP open message, and
Because the route-refresh
resumes normal peer-to-peer
request is not issued to the
message exchanges.
BGP neighbour, soft-
reconfiguration stores a
copy of BGP routes sent in
the BGP update from our
peer.
Direction The direction of connection in The direction of connection
hard reset can be both in and in soft reset is either in or
out. out.
Utilization It necessitates more RAM
of memory It does not necessitate any because the router now
additional RAM to store another stores two BGP tables for
table. each neighbour instead of
one.
Impact The hard reset has the Only those prefixes affected
potential to drastically impair by the policy change will be
network connectivity affected by the soft reset.
Use Case When a soft reset fails to The soft technique is the
resolve the problem, a hard most popular and widely
reset should be utilised as a employed.
Basis Hard Reset Soft Reset
final resort.
Prerequisit In soft reset with the Route
e refresh functionality, both
There are no requirements for
peers may be required to
this activity.
provide the Route Refresh
capability.
Rate Of Because processing the entire
Its convergence time is
Convergenc table takes a lengthy time, it
significantly less than that
e necessitates an extremely long
of a hard reset.
convergence time.
Commands clear ip bgp {neighbor ip}
Used soft out
clear ip bgp {* | neighbor ip |
peer-group}
clear ip bgp {neighbor ip}
soft in
20. What do the various BGP Path Attributes mean?
BGP offers a variety of Path Attributes, which are used to compare
competing BGP pathways (routes) in the BGP table to identify the best
possible path (route).
The following are some BGP Path Attributes:
Next Hop: The Next Hop Path Attributes are used to list the IP
address of the prefix's next hop. It determines whether the Next
Hop is achievable. The router does not use this route if no other
route can reach Next Hop.
Weight: When you receive updates from a router, the weight Path
Attributes is a numeric value provided by the router to impact the
route for a prefix. It is not publicised among BGP peers, and a
heavier weight is preferred.
Local Preference: Local Preference is a numeric value set as well.
It is conveyed within a single autonomous system in order for all
routers in that autonomous system to determine the optimum
route to a certain network. The higher the value, the better.
Routes injected locally: The routes injected with the network
command are known as locally injected routes. These are
preferable to iBGP/eBGP.
Multi-Exit Discriminator: The Multi-Exit Discriminator (MED)
allows one autonomous system to inform a neighbouring
autonomous system about the optimum path to take for packet
forwarding. The smaller the better.
AS Path: The number of ASNs (Autonomous System Number) in
the AS Path is specified by the AS Path. The smaller the better.
21. What do you understand about communities in the
context of BGP?
A BGP community is a transitive, optional BGP property that is
recognised and sent between BGP peers. A BGP community is a tag that
is appended to the BGP routes that are exchanged between two BGP
peers. A community is a 32-bit number that is divided into two 16-bit
sections. The first 16 bits indicate the community's AS number, while the
following 16 bits represent a unique number assigned by the AS.
Because each AS number is distinct, each community on the internet is
similarly distinct. This means that an AS with the ASN 9999 (or 0x270F in
hex) can have communities ranging from 0x270F0000 to 0x270FFFFF.
22. Explain the various types of communities used in BGP.
Following are the various types of communities used in BGP:
No-Advertise Community
When a route is associated with a No-Advertise community, the BGP
speaker will not advertise the route to any internal or external BGP
peers.
R1 does not advertise a No-Advertise Route (10.10.10.0/24) to peers
R11, R12, and R111 in the following example.
Community with No Exports
When a No-Export community is associated with a route, the router will
only advertise the route to internal peers.
R1, R11, and R12 are not advertising a No-Export Route (10.10.10.0/24)
to their external peer, R111, as seen in the following example.
R1 will not advertise the route to R111 in this situation, just to R11 and
R12, because they are internal BGP peers. As a result, because R111 is
an external BGP peer, R11 and R12 will not advertise either route to it.
Local AS Community
There is an important regulation about internal BGP neighbours to avoid
BGP routing loops: an IBGP neighbour cannot advertise a route to
another IBGP neighbour if it obtained that route from another IBGP
neighbour.
A Local AS Route (10.10.10.0/24) is not promoted between IBGP
neighbours (R11 and R111) within the local AS in the following example.
According to the criteria indicated above, R11 advertises the route to
R22, but R22 does not advertise the path to R111. There are several
options for getting the route to R111, including constructing a full mesh
of IBGP sessions between AS11 routers or dividing the AS 11 into a sub-
AS within a confederation.
Outside of AS11, no one knows what AS 1000 and AS1001 are. R111 can
now receive the 10.10.10.0/24 route even if it does not have full mesh
BGP peering. Outside of the sub-AS, the Local-AS community does not
advertise routes.
Graceful Shutdown Community
When a router's peer router is about to be purposely shut down, the
Graceful SHUTDOWN (65535:0) community is used to seamlessly shut
down paths it could use. Consider the following scenario: R111 is utilising
R11 to access the 10.10.10.0/24 network, but R11 will be rebooted to be
upgraded:
R111 replies by transferring traffic to R12 with minimum disruption when
R11 announces this community:
Extended Community
An Extended community is an 8-byte value that is split into two parts:
The first two bytes indicate the sort of community.
The last six bytes provide information that is specific to the type of
community.
There are three fields in an extended community: kind, administrator,
and assigned number (type:administrator:assigned-number). The
administrator field can be an AS or an IP address, depending on the
value of the high-order byte in the Type field. MPLS-VPN is the most well-
known use for extended communities, as it uses two extended
communities:
Route Target community: Determines which routers are capable of
receiving a given set of routes.
Route Origin community: This group of routers is responsible for
injecting a specified set of routes into BGP.
A Virtual Routing and Forwarding (VRF) table is a virtual routing table
that can have its own routing policies that are independent of the global
routing table or other VRFs. Essentially, you can connect numerous client
sites and create a distinct routing table (VRF) throughout the entire
network exclusively for this customer, with routing policies that differ
from those of other customers.
Route Target Community
In MPLS VPN setups, the Route Target community is used to segregate
two customers' routing tables, as depicted in the diagram below:
VRF Customer RED is only present on R1 and R12, and VRF Customer
BLUE is only present on R11 and R22 in this scenario, but they may have
been present on all four routers.
When a route is exported from VRF Red using BGP, the route-target
100:100 is assigned to the route. When the route reaches R12, the route
from R1 is imported, allowing the sites connected to R1 and R12 to
communicate.
Route Origin Community
The route origin community is used in an MPLS VPN environment to
identify where routes originated from so that readvertisement back to
that site is avoided.
When PE1 receives the route from CE1, it attaches the route origin
community in addition to the route-target that is linked to the route
(through export).
The route reaches PE2, but PE2 does not inform CE2 because it is aware
that it originated at the location.
23. What do you mean by BGP Message Types? Explain
the different Message Types in BGP in detail.
The BGP Message types are used to create a neighbour relationship and
exchange parameters such as the autonomous system number and
authentication values. A BGP message is made up of two parts: a BGP
header and data. The header format is the same in all of the BGP
messages. TCP is used to transmit BGP messages (port 179). The length
of the message ranges from 19 to 4096 octets. Each BGP message's
header is 19 octets long and consists of three fields.
The types of BGP messages are listed below:
Open : A BGP adjacency is established using the OPEN message.
Before a BGP peering is established, both parties negotiate session
capabilities. The BGP version number, ASN of the originating
router, Hold Time, BGP Identifier, and other optional characteristics
that define the session capabilities are all included in the OPEN
message.
Keepalive : To ensure that the neighbours are still alive, BGP does
not rely on the TCP connection status. Every one-third of the Hold
Timer agreed upon between the two BGP routers, keepalive
messages are exchanged. Generally, the default Hold Time for
devices is 180 seconds, so the default Keepalive interval is 60
seconds. No Keepalive messages are delivered between BGP
neighbours if the Hold Time is set to zero.
Update : The Update message can either advertise or remove
previously advertised routes, or it can do both. When advertising
prefixes, the Update message includes the Network Layer
Reachability Information (NLRI), which includes the prefix and
related BGP PAs. Only the prefix is included in NLRIs that have
been withdrawn. To save needless bandwidth, a UPDATE message
can be used as a Keepalive.
Notification : When a BGP session error is discovered, such as a
hold timer expiring, neighbour capabilities changing, or a BGP
session reset is requested, a Notification message is sent. The BGP
connection is closed as a result of this.
24. Explain the Path selection criteria used in BGP.
BGP seeks to reduce the number of paths available to only one best
path; it does not load balance by default. To do so, it looks at the
following path properties of any loop-free, synchronised (if
synchronisation is enabled) routes with an accessible next-hop:
Pick the route that has the most weight.
Choose the route with the highest local preference if weight is not
specified.
Choose routes that began with this router.
Choose the Autonomous System path that is the shortest.
Select the path with the lowest origin code (lowest is I next is e,
and last is?).
If the same Autonomous System advertises the available routes,
choose the path with the lowest MED.
Opt for an EBGP route rather than an IBGP route.
Choose the route that passes through the IGP neighbour with the
lowest IGP metric.
Pick the oldest route.
Choose the path that passes through the neighbour with the
smallest router ID.
Select the path that passes through the neighbour with the
smallest IP address.
25. Differentiate between Border Gateway Protocol (BGP)
and Routing Information Protocol (RIP).
Following are the differences between Border Gateway Protocol (BGP)
and Routing Information Protocol (RIP) :
Border Gateway Protocol
Routing Information Protocol (RIP)
(BGP)
It is based on the best-path The Bellman Ford algorithm is used by
algorithm. Routing Information Protocol.
Border Gateway Protocol
Routing Information Protocol (RIP)
(BGP)
In comparison to RIP, it is mostly
It is primarily utilised by companies of a
utilised for very large
smaller size.
organisations
It's a protocol for connecting to It is a dynamic routing protocol that is
an external gateway. widely used in the business.
In BGP, the networks are divided In RIP, areas, subareas, autonomous
into two categories: areas and systems, and backbone areas are the
tables. different types of networks.
The metric is calculated in terms The metric is calculated in terms of
of Hop Count. Bandwidth.
It is a hybrid type. It is a Vector State type.
There is no such limit on the
It allows for a total of 15 hops.
number of hops.
26. Differentiate between Enhanced Interior Gateway
Routing Protocol (EIGRP) and Border Gateway Protocol
(BGP).
Enhanced Interior Gateway Routing Protocol (EIGRP): If two
routers in the same area exist, EIGRP is used to share information
between them. It's also a complicated protocol, but it's simple to set up
and use in both small and big networks. It's also a hybrid protocol, as it
combines elements of both distance vector and link-state routing
protocols.
Following table lists the differences between Enhanced Interior Gateway
Routing Protocol (EIGRP) and Border Gateway Protocol (BGP):
Enhanced Interior Gateway Routing Border Gateway
Protocol (EIGRP) Protocol (BGP)
In EIGRP, the Dual Distance Vector Algorithm It is based on the best-path
is used. algorithm.
In comparison to EIGRP, it
It is primarily used by large organisations. is mostly used for very
large organisations.
It is a hybrid type. It's a type of Vector State.
It outperforms EIGRP in
It is a protocol for intelligent routing. terms of routing
intelligence.
It is a protocol for
It is a protocol for internal gateways. connecting to an external
gateway.
Its administrative distances
It has administrative distances of 90 (internal)
are 20 (internal) and 200
and 170 (external).
(external).
27. What do you understand about TTL Security in the
context of BGP? What is the need for TTL security in BGP?
When constructing an eBGP neighborship through a Service Provider
Network, there is a security risk of an attack from an unprotected
Internet Service Provider domain to a secured client environment. A
disadvantage of eBGP multihop is that a DOS attack can be carried out
by spoofing legal packets towards a BGP router in large numbers.
TTL-Security is a method we employ to secure our eBGP session from
DOS attacks like this. Only eBGP sessions, not iBGP sessions, can employ
the BGP TTL Security check. Only one of TTL Security and eBGP multihop
can be enabled to generate directly linked or multihop peering sessions.
A simple command can be used to configure the TTL-Security feature
against an eBGP neighbour:
neighbor TTL-security hops
By default, BGP sends packets with a TTL of 1 to external neighbours and
accepts packets with a TTL of 0 or higher from external neighbours (as
measured after the local router has decremented the TTL of the
incoming packet).
By requiring BGP to originate packets with a TTL of 255, the TTL-Security
modifies the default behaviour of originating.
28. What are the different types of loop prevention
mechanisms in BGP?
Following are the different ways of loop prevention mechanisms in BGP :
A router does not advertise the same routes to another iBGP peer
when one iBGP peer specifies routes for it.
When you use AS PATH, you can do the following: A BGP router
adds its own ASN to the AS PATH when we advertise to an eBGP
peer. When a BGP router receives an update and the route
announcement includes an AS PATH with its ASN, the route is
ignored.
Conclusion:
In this article, we have covered the most frequently asked interview
questions on Border Gateway Protocol (BGP). If you are preparing for a
BGP interview, you can expect questions from networking as well. Do not
worry, we got you covered. To go through the most frequently asked
interview questions on networking, visit this link.
BGP MCQ
1.
Which of the following routing methods best defines BGP?
distance vector
link-state
path-vector
hybrid of link-state and distance vector
2.
Which of the following statements concerning BGP is correct?
IBGP routes are never forwarded to EBGP peers.
BGP must not be enabled on all routers between IBGP neighbours.
IBGP acquired routes are never passed on to other IBGP peers.
IBGP is never used to learn routes.
3.
For normal BGP neighbour operations, which BGP neighbour state is
appropriate?
active
open confirm
idle
established
4.
When advertising to a BGP neighbour, which command makes the next-
hop address the source IP address of the update?
neighbor {ip-address | peer-group-name} next-hop-self
neighbor {ip-address | peer-group-name} update-source interface-
type interface-number
neighbor {ip-address | peer-group-name} remote-as autonomous-
system
neighbor {ip-address | peer-group-name} shutdown
5.
Which command resends the routing table without resetting the TCP
session and marks routes as "withdrawals" that the neighbour,
192.168.200.1, would no longer see? (If a BGP router's outbound policy
has changed, you should use this command.)
clear ip bgp 192.168.200.1
clear ip bgp *
clear ip bgp 192.168.200.1 soft in
clear ip bgp 192.168.200.1 soft out
6.
Which condition denotes that an open message has been delivered but
no response from the neighbour has been received in more than 5
seconds?
active
idle
established
open confirm
7.
Which command makes a BGP update's source IP address the IP address
of a specified interface?
neighbor {ip-address | peer-group-name} shutdown
neighbor {ip-address | peer-group-name} update-source interface-
type interface-number
neighbor {ip-address | peer-group-name} remote-as autonomous-
system
neighbor {ip-address | peer-group-name} next-hop-self
8.
Which command tells a BGP router whether an IP address is associated
with an IBGP or an EBGP neighbour?
neighbor {ip-address | peer-group-name} shutdown
neighbor {ip-address | peer-group-name} update-source interface-
type interface-number
neighbor {ip-address | peer-group-name} remote-as autonomous-
system
neighbor {ip-address | peer-group-name} next-hop-self
9.
By default, which of the following is NOT a way for IBGP neighbours to
generate an adjacency?
Neighbors can be connected directly.
Static routes allow neighbours to communicate with one another.
A dynamic internal routing system allows neighbours to communicate
with one another.
Neighbors may belong to distinct ASs.
10.
When an error condition is recognised, which BGP message is sent?
BGP update message
BGP notification message
BGP open message
BGP keepalive message
BGP error message
11.
What are the components of a BGP update?
multiple paths and multiple networks
a single path and multiple networks
a single path and a single network
multiple paths and a single network
12.
Which BGP message creates a BGP session and contains the BGP router
ID and hold time?
BGP update message
BGP keepalive message
BGP open message
BGP notification message
13.
What criteria does BGP use to choose the best path?
number of routers to reach a destination network
speed
AS routing policy
Delay + bandwidth
14.
Which command is the most inconvenient and should be avoided when
restarting BGP sessions?
clear ip bgp 192.168.200.1
clear ip bgp *
clear ip bgp 192.168.200.1 soft in
clear ip bgp 192.168.200.1 soft out
15.
What does the "s" in front of the line for a network imply in the output of
the show ip bgp command?
network summary
a network's subnet
a network's supernet
a suppressed network
BGP Interview Questions For
Experienced CCNA and CCNP Network
Engineers
In this article, you will find the most important and most asked BGP
Interview Questions For Experienced CCNA and CCNP Network
Engineers. It will cover all concepts of BGP (Border Gateway
Protocol) .
What is BGP?
BGP stands for Border Gateway Protocol and it is the main dynamic
routing protocol used on the Internet. BGP is for large networks and
is normally used for connecting different ISPs. Since BGP operates
with large amounts of data (the current size of the table for IPv4 is
more than 450 thousand routes), the principles of its configuration
and operation are different from the internal dynamic routing
protocols (IGP). BGP may be used for routing within an AS and
classified as IGP protocol while the other protocols may be referred
to as Exterior Border Gateway Protocol. BGP is considered as a path
vector protocol & it routing metric is based on paths, network-
policies sets by a network administrator.
What do you know about BGP, explain some basic
characteristics?
This is a General BGP Interview Question most face in a networking
job interview.
BGP is a path-vector protocol with the following common
characteristics:
Uses TCP to transfer data, this ensures reliable delivery of
protocol updates (port 179)
Sends updates only after network changes (no periodic
updates)
Periodically sends keepalive messages to verify TCP
connections.
The protocol metric is called path-vector or attributes.
What is the default administrative distance for BGP?
Following are the default administrative distance for BGP routes:
External BGP route=20
EGP route=140
External EIGRP route=170
Internal BGP route=200
When to use BGP?
BGP is a protocol for ISPs and it is like a distance-vector protocol. Its
hop count is an AS and that way it is also known as path vector
protocol. Normally we use the BGP in a large ISP environment. You
can establish a connection between different autonomous systems
by BGP. BGP is a good option in transit autonomous systems, which
means that you can allow your data packets to move through from
one autonomous system to another autonomous system.
What are the different modes of configuration for
BGP?
You can configure the BGP protocol according to your memory and
hardware requirements in the following ways:
Default route: In this mode of configuration ISP only advertises the
default route with BGP, and all other routes are accessible through
this default route. This is the most efficient way of configuration
when you have a small amount of memory.
Full updates: In this mode of configuration you will receive the full
routing table from ISP. This mode required a lot amount of memory.
Partial updates: In the partial update configuration mode of BGP
you will receive the routes for prefixes that are suitable to reach
from your ISP router. For other routes, you will also have a default
route.
Name a few well-known BGP metric attributes?
BGP path selection depends on the values of the following
attributes:
Weight(Cisco proprietary attributes )
Local Preference (highest local value will be preferred,
default value is 100)
Originate
AS path length
Origin code
MED
eBGP path over iBGP path
Shortest IGP path to BGP next hop
Oldest path
Router ID
Neighbor IP address
What Are Different BGP Message Types?
Open: Open message is Used to create a neighbor relationship and
exchange BGP=parameters, including AS number and
authentication values.
Keep-alive: These keepalive messages are sent periodically to
keep the neighbor relationship. If the Keep-alive messages are not
received within a Hold timer then BGP neighbor-ship will be broken
down.
Update messages: These messages are used to exchanges Path
Attributes and the associated prefix /length that use those
attributes.
Notification: In BGP notifications are used to report BGP problems
or errors. It results in a reset of the neighbor relationships.
What is IBGP and EBGP?
IBGP works within the single AS and transfer BGP routes within a
single autonomous system.
EBGP: BGP running between autonomous systems. By default, eBGP
neighbors must be directly connected.
Name some BGP Timers?
Keepalive Interval: The time interval in seconds,
between sending keep-alive messages. The default
keepalive timer is 60
seconds.
Hold Time: Interval in seconds, after which the neighbor
will be considered unavailable. The default is hold-down
time is 180 seconds.
Explain BGP Neighborhood relationships?
In BGP you are required to manually configure each neighbor in
order to establish a neighborhood relationship.
There are type of neighbors in BGP:
An internal BGP neighbor (iBGP neighbor) is a
neighbor that resides on the same AS as the local router.
iBGP neighbors do not have to be directly connected.
An external BGP neighbor (eBGP neighbor) is a
neighbor that is in an AS other than the local router.
EBGP neighbors must be directly connected by-default.
The type of neighbor has little effect on the setting of neighborhood
relations. More significant differences between the different types of
neighbors appear in the process of sending BGP updates and adding
routes to the routing table.
BGP performs these checks when it forms neighborhood
relationships:
The router should receive a request for a TCP connection
with the address of the sender, which the router
will find listed in the list of neighbors (the neighbor
command).
The autonomous system number of the local router must
match the autonomous system number, which is
indicated on the neighboring router by the command
neighbor remote-as (this requirement is not
observed when setting up confederations).
Router IDs must not be the same.
The neighbors must pass the authentication information
if it is configured.
What are the different Neighbor the Adjacency
States Of Bgp?
It is an important concept regarding BGP Interview Questions,
following are the Neighbor Adjacency States Of BGP:
Idle: The BGP process is either administratively down or waiting for
new neighbor adjacency.
Connect: During the BGP process, if the TCP connection is
successful, it will continue to the Open=Sent state. In case it fails, it
will continue to the Active state.
Active: BGP will try another TCP three-way handshake to create a
connection to the remote BGP-neighbor. If it is successful, it will
move to the Open-Sent state.
Open-sent: The TCP connection exists, and a BGP Open message
has been sent to the peer, but the matching Open message has not
yet been received from the other router.
Open-confirm: When an Open message has been received from a
neighbor router, a BGP Neighbor Adjacency is complete. A hold-
down timer will start once this is done.
Established: All BGP neighbor parameters matched, the neighbor
relationship has been established and the peers can now exchange
Update messages.
Can routers on different subnets become BGP
neighbors?
The answer is Yes. BGP routers become neighbors on different
subnets. Instead, BGP use a TCP connection between the neighbor
routers to pass BGP messages on the same or different subnet.
Which TCP port does BGP use?
Border Gateway Protocol uses TCP port number 179 for creating
connections. (Most common BGP interview questions.)
What is eBGP multihop?
When eBGP peers or routers are not directly connected with each
other. And there are one or more non-BGP peers to reach the BGP
router. You are required to configure the eBGP multihop to enable
the non-BGP routes to pass through the BGP neighbor relationship &
exchange update messages.
What is BGP TLL Security?
BGP TTL Security is a Security technique and Mechanism, which is
used to implemented/enhance the security of of the TCP connection
between BGP peers. You can secure a BGP connection by
disconnecting “faked TCP reset packets” from any other sources by
using the BGP TTL Security.
What is BGP path selection criteria?
If no path selection policies are configured for BGP on the Cisco
router. Then the router will go to each next step only if the values
match the previous one.
1. The maximum weight value (local to the router).
2. The maximum value of local preference (for the whole
AS).
3. Prefer the local route of the router (next hop = 0.0.0.0).
4. The shortest path through autonomous systems.
(shortest AS_PATH)
5. The minimum value of the origin code (IGP <EGP
<incomplete).
6. The minimum value of MED (distributed between
autonomous systems).
7. The BGP path is better than the iBGP path.
8. Choose a path through the nearest IGP neighbor.
9. Select the oldest route for the BGP path.
10. The neighbor with the lowest BGP router ID.
11. In last the neighbor with the smallest IP address.
(This is a very important BGP interview Question to remember. )
What is a transit AS?
With Transit AS you can transmit traffic of other autonomous
systems.
What is split-horizon?
Split horizon is a rule that routing information will not be sent back
to the router from which it is received. Mean routing information will
not send back in a direction from which side he received. This is a
very important concept and is used for preventing the routing loop
in a network.
(Alternatively, you may be asked this question in BGP interview
questions.)
What is Loop prevention mechanisms in BGP?
There are two mechanisms to prevent loops in BGP:
When we are advertising to an eBGP router/peer, a BGP
router adds its own A SN to the AS-PATH. If a
BGP router receives an update & route advertisement
lists an AS-PATH with its own ASN, then the router
ignores that route.
When a router learns routes from an iBGP peer, that
router does not advertise the same routes to another
iBGP peer.
Thank you for reading this, please add the “BGP Interview
Questions” in the comments that you have faced in a job interview
to improve this article.
Routing Path Determination
In this lesson, we will focus on Routing Path Determination. We
will learn how does a router select Best Route between different
routes. We will focus on Logest Prefix Match, Administrative
Distance (Preference) and Metric values of Routing Protocols.
This lesson is an important lesson of Routing and Cisco CCNA
Certification.
Table of Contents
Routing Decisions
o Longest Prefix Match
o Administrative Distance (Preference)
o Metric
Routing Decisions
When a packet comes to the router, the router checks the
destination network address if are there any match on the routing
table. Here, there are three alternatives or three different
situations. These are:
The destination network is directly connected.
The destination network is a remote network.
There is no route for the destination network.
If the destination network is directly connected, it is in the same
network with your source. So, router checks ARP cache and it
directly forwards the packet to the host on this local network.
If the destination network is a remote network, the router
encapsulates the frame and then forward it to the exit interface to
the next hop.
If there is no route for the destination network, then the data is
sent to the default route if are there any default route or gateway
of last resort. If there is no default route or gateway of last resort,
the packet is dropped.
Routing Tables stores these routes. So, how a router decides the
best path? Routers select the best paths according to some
parameters. These parameters are given below orderly:
Longest Match
Administrative Distance (Preference)
Metric
Now, let’s focus on these terms one by one and learn the details of
these
Longest Prefix Match
Longest Prefix Match is a best path selection mechanism used by
routers. This mechanism basically compares the destination IP
address and the routing table entry to determine the best available
route alternative. So how it does this mechanism work?
When router receives a packet, it compares the destination IP
address bit by bit with the entries in the routing table. The entry that
has the longest number of network bits which matches the
destination IP address, is selected as the best path.
Below, you can find an example of a Longest Prefix Match. Here, the
network bits that matches more with the destination, will be the
best path.
For this example, Route 3 is the best path.
Administrative Distance (Preference)
There can be different routing protocol on a router. And each routing
protocol learn the destination network in different ways. So, in the
routing table, there will be one more route for the same destination.
So, which will be the best route for that destination?
To overcome such an issue, Administrative Distance
(Preference) value is used. According to this value, each routing
protocol has an Administrative Distance (Preference) value by
default and this Administrative Distance value shows
the trustworthiness of the route. The lower numbers show the
more trustworthy routes. For example, if we have two routes to a
destination. One with OSPF and the other with Static Routing. By
default, the administrative distance value of OSPF is 110. And
administrative distance value of a static route is 1. So, if we have
two routes to the same destination in the routing table, static route
will be selected as best route. Because the preference value of static
route is lower than OSPF.
As a summary, Administrative Distance allows us to select the
route between different routing protocol route alternatives toward
the same destination.
Administrative Distance (Preference) vales are different in
different vendor devices. In other words, Cisco uses different
preference values than Juniper, Nokia, and Huawei. Below, you can
find the default administrative distance values for Cisco.
Connected 0
Static 1
EIGRP Summary Route 5
External BGP 20
Internal EIGRP 90
OSPF 110
IS-IS 115
RIP 120
External EIGRP 170
Internal BGP 200
You can also compare Cisco Default Administrative Distance
values with the Other Vendor’s preferences.
Metric
Metric is the value of the distance of a destination according to a
routing protocol. Each routing protocol use a different metric to
determine the distance of a destination. These metrics can be
determined according to a single or multiple characteristics of a
path.
For example, RIP uses hop counts a s metric. OSPF uses a
cumulative bandwidth of the complete path as a
metric. EIGRP uses more parameters to calculate metric like
Bandwidth, delay, load and reliability. Each of these metric
calculation mechanisms are specific to the routing protocol.
According to the metric mechanism of a routing protocol, each path
has a metric. Between these paths, the path that has lower metric,
is selected as the best route.
As a summary, with Metric, router selects the best route between
different path alternatives of the same Routing Protocol.