- [Instructor] We now want to take a look at some ways
that we can influence a BGP path selection.
There are some special cases where we may need
to override certain BGP default behaviors
and we're going to look at some of the ways
that we can do that.
In this first topology,
we're using a couple of routers R1,
an autonomous system 65100
and R2 an autonomous systems, 65200.
They're connected over a 10.1.1.0/24 network
and they're advertising their respective loop back addresses
that we can see here on the topology.
Loop back 1.1.1.1 for router one.
And Loop back 2.2.2.2 for router two.
Let's first look at using the local dash AS command.
This allows BGP sessions to be established
using an alternate autonomous system number.
Then the one under which the BGP process is running.
This is helpful in cases
where maybe you have a couple of corporate entities
or maybe their ISP and they're merging together
and you need an autonomous system to appear
as though it's running under an alternate number.
That's a method we can use to migrate sites together.
So in our case on R1,
we're already running under BGP process 65100,
and let's suppose that we want to
merge this with autonomous system number 100,
we're going to change our local BGP process
on this router to AS 100
but we're going to configure BGP to still appear
as 65100 to router two.
And that way we can bring our BGP peering back up
with router two,
without having to touch any of the configuration
on the remote router to pier.
So let's start on R1 and say,
show run the pipe two section BGP
just to see what we currently have in place.
You can see our existing process number BGP 65100
our autonomous system.
So let's go under global configuration mode
and let's take that out.
We'll say no router BGP 65100.
We're going to see our neighbor adjacency
with router two go down, so that's expected.
So now let's put a new process in place.
We'll say router BGP, autonomous system number 100.
And now we can point to our neighbor by saying neighbor
the IP address of router two is 10.1.1.2
that is in remote AS, 65200 pretty standard configuration
nothing new here, but when I hit enter
we're going to start getting some error messages.
And that's because on router two
our neighbor command, that's pointing to a router one
actually has remote AS 65100.
So it's expecting us to be
in that autonomous system, even though we're in AS 100 now
that's why we're getting those error messages
so we can make ourselves appear as an alternate ASN.
Then the BGP process 100 we're running under.
We do that by saying neighbor, again 10.1.1.2
And now we want to use the local dash AS keyword.
And that's going to let us indicate
a local autonomous system number for that router.
So we're going to say 65100,
which was our original autonomous system number.
And we'll give that just a moment.
And now you see, we have a neighbor adjacency.
It tells us that we are back in the upstate.
So even though we're not running BGP
ASN 65100 on this router, we're running under process 100
It still appears as though we are to router two.
So now let's also go ahead
and advertise our loop back address back out
by saying network 1.1.1.0
We'll put our mask in 255.255.255.0 will end.
And we'll again, say show run pipe to section BGP.
And you'll notice that now we're running
of course, router BGP, autonomous system, 100.
We have our neighbor
and the remote autonomous system 65200
but here is where we indicated that to this neighbor
we want to appear as autonomous system, 65100.
So let's jump over to router two and let's say show IP BGP.
And we see our advertised loop back prefix
from router one just as we would expect to see
we see the next hop is router one 10.1.1.1
and notice that the end
that now we have two autonomous system numbers
associated with this AS 100 and AS 65100
and we read this from right to left.
So this tells us that this prefix
of course originated in AS 100, which we're running under.
Then it went to 65100 before it came to our local ASF 65200.
So that's how we would use that local dash AS command.
Now, if we want to hide this particular AS
we can add a couple of optional keywords onto that command.
Let's go back to router one.
We'll go back under router BGP 100
and let's arrow up to get back to our neighbor command.
So there as our neighbor with a local AS of 65100,
and let's add the key word
no hyphen prepend and replace hyphen AS.
This is going to stop our prefix advertisements
from informing the router about our actual BGP process
that's running on the router.
So let's hit enter there and let's jump back to router two.
You'll see that we had a reset happen.
So our neighbor adjacency is back up now on router two.
So let's go here again and say show IP BGP.
So we again see our 1.1.1.0 prefix
coming from router one, the next hop.
But this time we only see the local AS that we indicated.
We don't see AS 100.
We only see the one that we indicated as the local AS
we have successfully stopped that ASN
for being advertised out to the router to pier.
Let's now look at the allow AS dash in option.
So let's say we have a typology as we see here,
we have three routers.
We have R1 and R3 both in autonomous system 65100
and we have R2 in 65200.
So let's suppose that the AS 65100 routers
are from the same customer
but they're in two different locations.
So we have two different locations, two different networks
using the same autonomous system number
what's going to happen is a BGP loop prevention mechanism
is going to check for incoming prefixes
and make sure that they're not originating
from the same autonomous system number
that the local router is in.
So essentially what's going to happen is
the advertised prefix from R3
are not going to appear on R1 because of this,
because it's going to know
that it's in its own autonomous system number.
We can override that with the allow AS dash in command
and specifically allow those prefixes to come in.
I already have a BGP neighbor adjacency
between all of the routers and again, they're advertising
their loop back addresses R1 being 1.1.1.1
R2 at 2.2.2.2 and R3 at 3.3.3.3.
Let's start on R2 and let's say show IP BGP.
And we can see that we're able to see
both the 1.1.1.0 prefix and the 3.3.3.0 prefix.
As we would expect to see both coming from
autonomous system 65100.
If we go to R1 and do the same thing, say show IP BGP.
Notice we do not see the 3.3.3.0 network from router three.
And that's because that prefix is arriving from the same
autonomous system number that we're currently in.
So if you have a situation like this,
we can run a very simple command to correct that
on router one, let's go under global configuration mode
and our local BGP router BGP 65100,
and let's say neighbor 10.1.1.2
and we want to say allow AS dash in.
That's the key word that we want to use.
And this is going to allow the route
to now be installed in the BGP table.
So let's break out of here and let's again, run
show IP BGP this time notice we do see the 3.3.3.0 network.
We see that at first comes from 65100,
and then it goes to router two as 65200
before arriving here locally on this router
we can, of course also do the same thing
on router three to make sure we're not getting
a similar situation on that side.
Let's now look at the AS path prepend option.
We have the following topology
containing four autonomous system numbers.
You can see an autonomous system
1000 were connected out to the internet.
And that happens from R1, which we have two paths.
We can go through autonomous system number 200
or autonomous system number 300
routers two and three respectively.
We want R1 to prefer the path through AS 200.
And we can do that with the AS prepend command.
Remember the AS path attribute
which we can see in the output of our show, IP BGP command
and that's a well known, mandatory attribute.
So it's present for all exchanged prefixes
between BGP peers.
That's used for loop prevention
by prepending or adding an autonomous system number two,
the traffic path we can artificially make a route
appear longer than it actually is
which is going to influence our BGP path selection.
Let's see how this is done.
First on our internet router
let's say show IP BGP 1.1.1.0/ 24.
That is the loop back address for R1.
And that prefix is being advertised through BGP.
Now you can see here, we actually have two paths available.
It tells us right here
and we see one through 3.3.3.3 which is router three.
And we see that's listed as the best path currently.
We also see a path through 2.2.2.2
which is of course, router two.
We can also see this if we say show IP BGP,
where we can see the 1.1.1.0 network.
And we see there are two paths listed for that.
The best path is indicated by this greater than sign.
You can see up here
in our status codes that tells us this is the best route.
And that route starts in autonomous system 100,
which is router one,
and then goes through autonomous system 300,
which is router three.
Again, R3 is listed as the best path.
So let's use the AS path prepend option to influence BGP
to prefer the AS 200 route over route two.
So let's first go to router one,
we'll go under global configuration mode
and we'll first go on to create a prefix list.
And this prefix list is going to permit
all of our prefix advertisements.
So let's say IP prefix hyphen list.
We'll call this as 100.
We have a loop back network being advertised
which is 1.1.1.0/ 24.
So let's say permit
actually, I need to put my permit statement first.
I put that in backwards almost.
So permit 1.1.1.0/ 24.
So we have that very simple IP prefix list.
And now let's create a couple of route maps.
One of those is going to have the prepend option
and one will not have the prepend option.
So first let's say route hyphen map
and we'll name the first one AS 100.
We'll hit enter to go under route map configuration mode
and we'll say match IP address.
And we want to match that to
a prefix list, which is AS 100 we hit enter there.
We'll back up a step back into global configuration mode
and we'll create another route map called AS 100
I'll call this one prepend
and I'm again going to match the IP address
for our prefix list AS 100.
This time though
we're going to prepend our own autonomous system number
onto this route map
so that we can influence our path
and make this path look longer than it actually is.
So let's hit enter first
and we'll say set AS, hyphen path and we want to say prepend
and then we'll indicate if we look at contextual help
we can indicate our autonomous system number.
So we're just going to put our own autonomous system number.
We're going to prepend that there
and if we look at contextual help
we can continue to put those in there.
I'm going to add that on there twice a second time.
So I'm going to say set AS path prepend 100, 100
and I'll hit enter.
Now we can exit back to global configuration mode
and we want to assign these route maps to our neighbors.
Since we want to influence our path to take AS 200
let's apply the route map
with the AS prepend option to neighbor R3 in AS 300.
So let's go under router BGP 100.
We'll hit enter and we'll use a neighbor command.
We'll say neighbor 20.1.1.2
and we'll say route hyphen map
followed by the name of our route map, which is AS 100
and again, we want to use the one
with the prepend option attached to that.
And of course we want to finally indicate our direction
which we want to be outbound.
Now we can do the same thing for neighbor R2 in AS 200.
So let's say neighbor 10.1.1.2 route hyphen map.
This time we'll use our AS 100 route map
again in the outbound direction.
Let's jump back over to our internet router
which is AS 1000
and this is our, again, our internet transit router.
So let's look at our BGP table.
Let's say show IP BGP
and you'll notice right here was our original output.
Remember our best path was indicated as
starting in AS 100 and then going to AS 300.
Now our best path has indeed changed
thanks to our prepend option.
Now the best path is seen as going from 100 to 200.
So in other words
going from router one to router two
and then out to the internet,
we can see our prepended AS numbers here
our AS 100 that we added
on there twice to artificially make that path seem longer.
So this is exactly what we want to see.
We've artificially influenced our path
to seem that the shortest path is through AS 200.
So that's a look at several options we have
for influencing our BGP path selection.