Whenever there’s a weird request to do something totally illogical with BGP, there’s a knob in Cisco IOS to get it done (and increase the heartburn of CCIE candidates). Conditional Route Injection (the ability to insert more specific prefixes into BGP without having them in the IP routing table) is one of them.
What is Conditional Route Injection? A feature that allows you to insert more-specific prefixes into the BGP table of a router (to have them advertised to its peers) without having them in the IP routing table.
Why would you need it? Traffic engineering (splitting inbound traffic by advertising more-specific prefixes over individual uplinks) immediately comes to mind, and I’m positive there are other creative uses tied to well-known mobility myths. Anything else? Please write a comment – I would really love to know who uses this feature and why.
Configuring Conditional Route Injection
The configuration seems easy:
- Configure a prefix-list listing all more-specific prefixes you want to insert;
- Configure a route-map using the above prefix-list in set ip address statement;
- Configure another prefix list matching the less-specific aggregate prefix;
The prefixes you want to insert into the BGP table MUST be more specific prefixes of the one(s) matched by this prefix list.
- Configure a third prefix list matching the source (advertising router) of the less-specific aggregate prefix;
- Configure a second route map that matches the aggregate IP prefix with match ip address prefix-list statement and originating router with match ip route-source prefix-list statement;
The route map matching the aggregate prefix MUST have the match ip route-source statement; without it, the more-specific prefixes are not inserted.
- Use both route maps in bgp inject-map router configuration command.
The requirement to match on IP route source seems annoying, but is actually quite cool. It allows you (for example) to advertise more specific prefixes for locally-advertised aggregates, but not for aggregates received from other locations (see this video for more details).
Here’s a working configuration that inserts two hosts routes (192.168.10.2/32 and 192.168.10.3/32) when the router receives 192.168.10.0/24 from BGP neighbor 192.168.0.1.
router bgp 65001
bgp inject-map HOSTS exist-map SUBNET copy-attributes
ip prefix-list HOSTS seq 5 permit 192.168.10.2/32
ip prefix-list HOSTS seq 10 permit 192.168.10.3/32
ip prefix-list RRC seq 5 permit 192.168.0.1/32
ip prefix-list SUBNET seq 5 permit 192.168.10.0/24
route-map SUBNET permit 10
match ip address prefix-list SUBNET
match ip route-source prefix-list RRC
route-map HOSTS permit 10
set ip address prefix-list HOSTS
The aggregate (less-specific) prefix MUST come from a BGP neighbor. Whoever designed this feature had enough common sense not to allow insertion of more-specific prefixes of a locally-originated prefix.