More Narbik Labs. I have arrived at the BGP section, and its very good. It touches on some more obscure features that are really useful.
One of the things i ran into was the use of advertise-maps, exist-maps and non-exist maps. I have used these before, but very briefly.
I also have notes on the use of the mentioned maps, but its one of those things that if you dont use it, you forget it. When i read the task description i immediately
thought of using route-maps in some way. However, the task required some conditional requirements. More specifically, if this network exist
advertise this other network, otherwise dont. Right there, that cancelled my immediate idea.
So lets take a look at the suggested way of accomplishing this task. Namely using advertise-maps, exist-maps and non-exist-maps.
First of, our topology:
To begin with, we create a normal iBGP peering. I will not go into detail on how to do this since its documented so well alot of different places, including Cisco’s DocCD.
We then advertise all loopbacks on both R1 and R2. Lets verify that its all working so far:
R1(config-router)#do sh ip bgp Network Next Hop Metric LocPrf Weight Path *> 22.214.171.124/24 0.0.0.0 0 32768 i *>i126.96.36.199/24 192.168.12.2 0 100 0 i *> 188.8.131.52/24 0.0.0.0 0 32768 i
*Note, that i cut some output out to breviate the post.
Its all working so far, lets include R2 for completeness:
R2(config-router)#do sh ip bgp Network Next Hop Metric LocPrf Weight Path *>i184.108.40.206/24 192.168.12.1 0 100 0 i *> 220.127.116.11/24 0.0.0.0 0 32768 i *>i18.104.22.168/24 192.168.12.1 0 100 0 i
Alright, we are seeing the routes appear as we expected to.
Lets get to the advertise-map part.
These maps will be applied on a per neighbor basis. Ask the following question: “What prefixes do we want to send to this neighbor under what circumstances?”.
As with any other neighbor parameter, it will be under the router-config and after a neighbor command:
R1(config-router)#neighbor 192.168.12.2 ? activate Enable the Address Family for this Neighbor advertise-map specify route-map for conditional advertisement
Now, lets define our task. We want to advertise the 22.214.171.124/24 route IF the 126.96.36.199/24 route exists in our BGP table.
First, lets create a couple of access-lists that define the networks 188.8.131.52/24 and 184.108.40.206/24:
R1(config)#access-list 1 permit 220.127.116.11 0.255.255.255 R1(config)#access-list 2 permit 18.104.22.168 0.0.0.255
We actually HAVE to match the inverse of the network in order for it to work. This only goes for the exist-map. There are some discrepancies here. If we create an ACL with the network not inversely matched, but later in the ACL creates one that is, the first ACE will be hit (sh access-list). Go figure.
Now to our maps. What we really want to create is some route-maps. Lets create our advertise map first. This map defines what network we want a condition on:
R1(config)#route-map AD-MAP R1(config-route-map)#match ip add 1
Next up, lets create our exist-map. This map defines what routes must exist in our BGP table, if the previous (advertise-map) should be advertised:
R1(config)#route-map EXIST-MAP R1(config-route-map)#match ip add 2
Finally we need to apply the two maps to get the functionality we want. We do this with the neighbor command as we started out with:
R1(config-router)# neighbor 192.168.12.2 advertise-map AD-MAP exist-map EXIST-MAP
Lets then do a soft-reconfig outbound to the neighbor in order to avoid the pacing-walk timer, which i believe is 60 seconds:
R1#clear ip bgp 192.168.12.2 out
Now, the network we are “meassuring” on, is loopback1 on R1, which is up now, so we expect 22.214.171.124/24 being advertised to R2:
R1#sh ip bgp nei 192.168.12.2 advertised-routes Network Next Hop Metric LocPrf Weight Path *> 126.96.36.199/24 0.0.0.0 0 32768 i *> 188.8.131.52/24 0.0.0.0 0 32768 i
And on R2:
R2#sh ip bgp Network Next Hop Metric LocPrf Weight Path *>i184.108.40.206/24 192.168.12.1 0 100 0 i *> 220.127.116.11/24 0.0.0.0 0 32768 i *>i18.104.22.168/24 192.168.12.1 0 100 0 i
So far, so good. Everything is working fine, and R2 is getting our “questionable” route.
Lets shut down loopback1 on R1 and see what happens with 22.214.171.124/24:
R1(config-if)#do sh ip bgp nei 192.168.12.2 adver Total number of prefixes 0
Nothing! (remember that we shut down loopback1, so 126.96.36.199/24 went away automatically). Now R2 to verify it completely:
R2#sh ip bgp Network Next Hop Metric LocPrf Weight Path *> 188.8.131.52/24 0.0.0.0 0 32768 i
Great! our conditional advertisement works as planned. Task completed.
Lets recap. We created an advertise-map called AD-MAP. This map tells the router, that this is the network in
question. If our exist-map ends up being true the network in the advertise-map will be advertised. This exist-map is called EXIST-MAP and tells the router that if the network listed in this
exist-map is in the BGP table we want to advertise the network listed in the AD-MAP. If it doesnt exist in the BGP table, we DONT want to match it.
I hope this has been entertaining and has clarified on how and when to use advertise-maps!