AS the name of topic, we will make the conditional routing / route advertisement. We will achieve this by injecting routes using inject-map and exit-map.
We will use prefix-list instead of ACL. You should also avoid the ACLs when configuring conditional routing.
Injected route must be part or subset of an aggregated route and this aggregated route should be present in routing table.
Note: inject-map is not a normal map. So it can be configure only under the BGP and can’t be configure per peer basis.
Below is our topology:
In above topology we are having only two routers and these are connected directly.
R1 aggregated few prefixes and advertising a aggregated prefix 10.10.10.0/26 to R2.
Now we will configure the R2 to inject 10.10.10.48/28 prefix.
First we will configure the prefix-lists which will be call inside the maps.
ip prefix-list EXIST seq 5 permit 10.10.10.0/26
We are using EXIT name for prefix-list because we will call it under EXIT-MAP. So it will be easy to remember. We are using /26 aggregated prefix that means we will call aggregated prefix in EXIT-MAP
ip prefix-list INJECT 5 permit 10.10.10.48/28
We are using prefix=list name INJECT and we will call it under INJECT-MAP. We are configuring the prefix under this prefix-list/inject-map which we want to inject.
ip prefix-list SOURCE seq 5 permit 192.168.1.1/32
This is the router-id and will be use for source. This is also a important part. If source is not correct or not reachable then we will not get expected output.
We have configured the prefix-lists. So now our second task is map. We will configure the maps as below.
route-map INJECT permit 10 set ip address prefix-list INJECT
Keep in mind and don’t forgot. We have to use SET command for inject the prefix. If you will use MATCH command by mistake then this command will not perform its function.
route-map EXIST permit 10 match ip address prefix-list EXIST match ip route-source prefix-list SOURCE
you can see above configuration. We have called all three prefix-lists in MAPs.
We have already configure the prefix-lists and maps. So now we will apply these maps under the BGP as below.
route bgp 100 bgp inject-map INJECT exist-map EXIST
Now we will verify the output to make sure that our maps are working or not.
R1#show ip bgp nei 192.168.2.2 advertised-routes | begin Net Network Next Hop Metric LocPrf Weight Path *> 10.10.10.0/26 192.168.8.8 0 200 0 20 1 i
In above output, we are still having /26 prefix which is preferring by BGP. Are you little bit confused ? no worry. Actually, if you will see the above output, R1 is advertising /26 to R2. But we had configured to R2 to inject /28. We were not doing the configuration on R1. We were doing the configuration on R2. So lets check on R2.
R2#sh ip bgp injected-paths | begin Net Network Next Hop Metric LocPrf Weight Path *>i10.10.10.48/28 192.168.1.1 0 200 0 20 1 i
Above output is clearly showing that /28 prefix has been injected on R2. If you will see we didn’t advertised /28 from any router to R2. But this prefix is in BGP table of R2.
Once again, I want to repeat that injected prefix should fall under a aggregated route and this aggregated route should be present in table. Otherwise, prefix will not inject. As well as source should be correct and reachable.