BGP Conditional Route Injection & Advertisement
The BGP conditional route injection feature allows the creation of more-specific prefixes
when an aggregate exists. These prefixes are injected in to local BGP table to provide
more specific routing information in local AS than aggregated route. This can be used to
optimize the exit points of the local AS.
The BGP conditional advertisement feature provides additional control of route
advertisement, depending on the existence of other prefixes in the BGP table. This can be
useful for a multihomed AS that wants to only use one ISP peering (expensive) if the
other one of down.
R1 configuration
router bgp 100
network 1.1.1.0 mask 255.255.255.128
network 1.1.1.128 mask 255.255.255.128
network 11.11.11.11 mask 255.255.255.255
aggregate-address 1.1.1.0 255.255.255.0 summary-only
neighbor 12.12.12.2 remote-as 200
R2 configuration
router bgp 200
bgp inject-map PREFIX-INJECTIONS exist-map AGGREGATED-ROUTE
network 2.2.2.2 mask 255.255.255.255
neighbor 12.12.12.1 remote-as 100
neighbor 23.23.23.3 remote-as 300
neighbor 23.23.23.3 advertise-map TO-AS300 non-exist-map FROM-AS100
ip as-path access-list 1 permit ^100
ip prefix-list R1-AGGREGATE seq 5 permit 1.1.1.0/24
ip prefix-list R1-LOOPBACK seq 5 permit 11.11.11.11/32
ip prefix-list R1-SOURCE seq 5 permit 12.12.12.1/32
ip prefix-list R2-LOOPBACK seq 5 permit 2.2.2.2/32
ip prefix-list UNAGGREGATED-PREFIXES seq 5 permit 1.1.1.0/25
ip prefix-list UNAGGREGATED-PREFIXES seq 10 permit 1.1.1.128/25
route-map TO-AS300 permit 10
match ip address prefix-list R2-LOOPBACK
route-map FROM-AS100 permit 10
match ip address prefix-list R1-LOOPBACK
match as-path 1
route-map PREFIX-INJECTIONS permit 10
set ip address prefix-list UNAGGREGATED-PREFIXES
route-map AGGREGATED-ROUTE permit 10
match ip address prefix-list R1-AGGREGATE
match ip route-source prefix-list R1-SOURCE
R3 configuration
router bgp 300
neighbor 23.23.23.2 remote-as 200
Conditional route injection verification
R1(config-router)#do sh ip bgp
BGP table version is 6, local router ID is 1.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i -
internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
s> 1.1.1.0/25 0.0.0.0 0 32768 i
*> 1.1.1.0/24 0.0.0.0 32768 i
s> 1.1.1.128/25 0.0.0.0 0 32768 i
R2(config-router)#do sh bgp injected-paths
BGP table version is 8, local router ID is 2.2.2.2
Status codes: s suppressed, d damped, h history, * valid, > best, i -
internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 1.1.1.0/25 12.12.12.1 0 ?
*> 1.1.1.128/25 12.12.12.1 0 ?
00:52:52: BGP(0): updating injected prefix 1.1.1.0/25, from source
prefix 1.1.1.0/24
00:52:52: BGP(0): updating injected prefix 1.1.1.128/25, from source
prefix 1.1.1.0/24
00:52:52: BGP(0): retaining injected prefix 1.1.1.0/25, from source
prefix 1.1.1.0/24
00:52:52: BGP(0): retaining injected prefix 1.1.1.128/25, from source
prefix 1.1.1.0/24
R3#sh ip bgp
BGP table version is 8, local router ID is 23.23.23.3
Status codes: s suppressed, d damped, h history, * valid, > best, i -
internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 1.1.1.0/25 23.23.23.2 0 200 ?
*> 1.1.1.0/24 23.23.23.2 0 200 100 i
*> 1.1.1.128/25 23.23.23.2 0 200 ?
Conditional route advertisement verification
R2#sh ip bgp neighbors 23.23.23.3 | i Condition
Condition-map FROM-AS100, Advertise-map TO-AS300, status: Withdraw
R3(config-router)#do sh ip bgp
BGP table version is 21, local router ID is 23.23.23.3
Status codes: s suppressed, d damped, h history, * valid, > best, i -
internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 11.11.11.11/32 23.23.23.2 0 200 100 i
R3(config-router)#do sh ip bgp 2.2.2.2
% Network not in table
01:25:48: %BGP-5-ADJCHANGE: neighbor 12.12.12.1 Down BGP Notification
sent
01:25:48: %BGP-3-NOTIFICATION: sent to neighbor 12.12.12.1 4/0 (hold
time expired) 0 bytes
01:25:50: BGP(0): no valid path for 11.11.11.11/32
01:25:50: BGP(0): nettable_walker 11.11.11.11/32 no best path
01:25:50: BGP(0): 23.23.23.3 send unreachable 11.11.11.11/32
01:25:53: BPG(0): Condition FROM-AS100 changes to Advertise
01:25:53: BGP(0): net 2.2.2.2/32 matches ADV MAP TO-AS300: bump version
to 22
01:25:53: BGP(0): nettable_walker 2.2.2.2/32 route sourced locally
01:26:17: BGP(0): 23.23.23.3 2.2.2.2/32 matches advertise map TO-AS300,
state: Advertise
01:26:17: BGP(0): 23.23.23.3 send UPDATE (format) 2.2.2.2/32, next
23.23.23.2, metric 0, path
R2#sh ip bgp neighbors 23.23.23.3 | i Condition
Condition-map FROM-AS100, Advertise-map TO-AS300, status: Advertise
R3(config-router)#do sh ip bgp
BGP table version is 16, local router ID is 23.23.23.3
Status codes: s suppressed, d damped, h history, * valid, > best, i -
internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 2.2.2.2/32 23.23.23.2 0 0 200 i
01:30:11: %BGP-5-ADJCHANGE: neighbor 12.12.12.1 Up
01:30:11: BGP(0): 12.12.12.1 rcvd 11.11.11.11/32
01:30:11: BGP(0): Revise route installing 1 of 1 route for
11.11.11.11/32 -> 12.12.12.1 to main IP table
01:30:53: BPG(0): Condition FROM-AS100 changes to Withdraw
01:30:53: BGP(0): net 2.2.2.2/32 matches ADV MAP TO-AS300: bump version
to 27
01:30:54: BGP(0): nettable_walker 2.2.2.2/32 route sourced locally
01:30:54: BGP(0): 23.23.23.3 2.2.2.2/32 matches advertise map TO-AS300,
state: Withdraw
01:30:54: BGP(0): 23.23.23.3 send unreachable 2.2.2.2/32
01:30:54: BGP(0): 23.23.23.3 send UPDATE 2.2.2.2/32 -- unreachable
Comments
For conditional route injection: you must use Prefix-lists, NOT ACLs.
We can only originate more specific subnets of an existing aggregate prefix.