BGP (Border Gateway Protocol) is the routing protocol that glues the Internet together. I’m going to explain in which situations we need BGP and how it works.
In this blog we will discuss how to configure EBGP (External BGP) and how to advertise networks. The following topology will be used:
eBGP (external BGP) by default requires two Cisco IOS routers to be directly connected to each other in order to establish a neighbor adjacency. This is because eBGP routers use a TTL of one for their BGP packets. When the BGP neighbor is more than one hop away, the TTL will decrement to 0 and it will be discarded.
Let’s start with an example topology and I’ll explain a couple of things:
When you configure BGP on a router it’s possible that some of the BGP neighbors share the exact same configuration. This can be annoying since you have to type in the exact same commands for each of these neighbors. Also, when BGP prepares updates it does this separately for each neighbor. This means that it has to use CPU resources to prepare the update for each neighbor.
Just like IP addresses, ASNs (Autonomous System Numbers) have to be unique on the Internet. The main reason for this is that BGP uses the AS number for its loop prevention mechanism. When BGP learns about a route that has its own AS number in its path then it will be discarded.
Here’s an example:
All prefixes that BGP learns are stored in the BGP table. In this blog we’ll take a look at this table and we will learn how to read it. We’ll start with a simple topology and finish with a quick peek at a full Internet routing table.
In this blog, we’ll take a look how you can advertise networks in BGP. There are two methods how we can do this:
- Network command
In a previous blog, we discussed how the BGP network command works. When we enable auto-summary for BGP, the way the network command works changes slightly.
Normally when you advertise a network in BGP you have to type in the exact network and subnet maskthat you want to advertise or it won’t be placed in the BGP table.
One potential issue with iBGP is that it doesn’t change the next hop IP address. Sometimes this can cause reachability issues. Let’s look at an example:
Just like OSPF or EIGRP, BGP establishes a neighbor adjacency with other BGP routers before they exchange any routing information. Unlike other routing protocols however, BGP does not use broadcast or multicast to “discover” other BGP neighbors.
BGP uses a variety of messages for establishing the connection, exchanging routing information, checking if the remote BGP neighbor is still there and/or notifying the remote side if any errors occur.
To do all of this, BGP uses 4 messages:
Weight is a Cisco proprietary BGP attributes that can be used to select a certain path. Here’s what you need to know about weight:
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:
The BGP Origin Code is one of the attributes that is used for path selection. There are three origin codes that the BGP table can show:
MED (or metric) is the sixth BGP attribute:
- MED can be used to advertise to your neighbors how they should enter your AS.
- MED is exchanged between autonomous systems.
- The lowest MED is the preferred path.
- MED is propagated to all routers within the neighbor AS but not passed along any other autonomous systems.
Regular Expressions are used often for BGP route manipulation or filtering. In this blog we’ll take a look at some useful regular expressions. First let’s take a look at the different characters that we can use:
In this blog, we’ll take a look at BGP AS path filtering. Using the AS path filter we can permit or deny prefixes from certain autonomous systems. You can use this for things like:
By default BGP will advertise all prefixes to EBGP (External BGP) neighbors. This means that if you are multi-homed (connected to two or more ISPs) that you might become a transit AS. Let’s look at the following example:
When we change the BGP routing policy (changing the attributes or adding filters) we need to reset the BGP session before the new policy takes effect. This is no problem in a lab but it’s something you don’t want to do in a production network. In fact, there are 3 methods how you can refresh your BGP policies:
A long time ago there was no method to dynamically request a re-advertisement of the prefixes of one of your BGP neighbors. When you change your policy, somehow you have to compare all the prefixes from your BGP neighbor against your new policy.
The normal version of BGP (Border Gateway Protocol) only supported IPv4 unicast prefixes. Nowadays we use MP-BGP (Multiprotocol BGP) which supports different addresses: