As mentioned in the Part-1 of the loop prevention, that we will
be continuing the loop prevention with as path list. Let us just dig directly
to the configuration and you will know everything.
First we need to remove the previous configuration we did
for loop prevention
R1(config-router)#no neighbor 1.1.1.2 route-map LOCAL out
R1(config-router)#no neighbor 1.1.1.6 route-map LOCAL out
Lets clear the bgp softly and confirm if we are again
advertising irrelevant routes
R1(config-router)#do clear ip bgp * so
R1(config-router)#do sh ip bgp nei 1.1.1.2 ad |
b Net
Network Next Hop Metric LocPrf Weight Path
*>
4.4.4.0/30 1.1.1.2 0 2 1 ?
*>
4.4.4.4/30 1.1.1.2 0 2 1 ?
*>
10.10.10.0/24 0.0.0.0 0 32768 ?
*>
20.20.10.0/24 1.1.1.2 0 2 1 ?
*>
20.20.11.0/24 1.1.1.2 0 2 1 ?
*>
20.20.12.0/24 1.1.1.2 0 2 1 ?
*>
20.20.13.0/24 1.1.1.2 0 2 1 ?
*>
20.20.14.0/24 1.1.1.2 0 2 1 ?
*>
20.20.15.0/24 1.1.1.2 0 2 1 ?
*>
20.20.16.0/24 1.1.1.2 0 2 1 ?
*>
20.20.17.0/24 1.1.1.2 0 2 1 ?
Total number of prefixes 11
R1(config-router)#do sh ip bgp nei 1.1.1.6 ad |
b Net
Network Next Hop Metric LocPrf Weight Path
*>
4.4.4.0/30 1.1.1.2 0 2 1 ?
*>
4.4.4.4/30 1.1.1.2 0 2 1 ?
*>
10.10.10.0/24 0.0.0.0 0 32768 ?
*>
20.20.10.0/24 1.1.1.2 0 2 1 ?
*>
20.20.11.0/24 1.1.1.2 0 2 1 ?
*>
20.20.12.0/24 1.1.1.2 0 2 1 ?
*>
20.20.13.0/24 1.1.1.2 0 2 1 ?
*>
20.20.14.0/24 1.1.1.2 0 2 1 ?
*>
20.20.15.0/24 1.1.1.2 0 2 1 ?
*>
20.20.16.0/24 1.1.1.2 0 2 1 ?
*>
20.20.17.0/24 1.1.1.2 0 2 1 ?
Total number of prefixes 11
Yes we are. Seems goog so far
No need to remove the route-map since it is not called
anywhere else. Now we will configure the filter list using as-path list.
R1(config)#ip as-path access-list 10 permit ^$
Here we are using BGP Regular expression often known as
regex (pronounced as rej-ex). BGP Regex are often used for filtering some type
of routes as well as when we require some special behavior on the routes of
respected AS. There are many characters that can be used as regular expression.
Some of them are
^
|
Matches the beginning of the string
|
&
|
Matches the end of the string
|
*
|
Repeats the string many times
|
[]
|
You can use range of AS-path between the brackets
|
You can see all the list of cisco BGP regular expressions
from here
.
In our case, what we are trying to say is; match anything between
the begging of the string‘^’ and the end of the string and then permit them permit ^$. But we are not
matching anything between the start and the end of the string. That means there
is no match and hence only local routes will be advertised 😊
Now we will call the as-path access-list under BGP neighbor
R1(config)#router bgp 1
R1(config-router)# neighbor 1.1.1.2 filter-list
?
<1-500> AS path access list
Here we will call the exact as-path access-list number,
which in our case is 10
R1(config-router)# neighbor 1.1.1.2 filter-list
10 ?
in Filter incoming routes
out Filter outgoing routes
again, we need a match on the outbound
R1(config-router)# neighbor 1.1.1.2 filter-list
10 out
The same goes for the other neighbor as well
R1(config-router)# neighbor 1.1.1.6 filter-list
10 out
Let us soft clear the bgp and check the advertised routes
R1(config-router)#do clear ip bgp * so
R1(config-router)#do sh ip bgp nei 1.1.1.2 ad |
be Net
Network Next Hop Metric LocPrf Weight Path
*>
10.10.10.0/24 0.0.0.0 0 32768 ?
Total number of prefixes 1
R1(config-router)#do sh ip bgp nei 1.1.1.6 ad |
be Net
Network Next Hop Metric LocPrf Weight Path
*>
10.10.10.0/24 0.0.0.0 0 32768 ?
Total number of prefixes 1
Yup, that was required. We are only advertising only local
routes. There can be other ways to achieve the same results but I found
route-map and the as-path access-list easiest one.
That all for today. I hope both parts of BGP loop prevention
was useful. If you know any other easier method , Please do let me know .
No comments:
Post a Comment