Conditional Advertisement
Topology: russo-bgp-iol

Load unix:lab1.init.cfg
#R1-R6
configure replace unix:lab1.init.cfg
This is the Nick Russo BGP Multi-Homing topology using IOL nodes.
Configure R4 and R5 to advertise an IPv4 and IPv6 default route to R6.
R6 should prefer the default routes via R4.
Configure R6 to only advertise its IPv4/IPv6 loopback addresses to R5 if the default route via R4 is gone.
Answer
#R4
router bgp 65000
add ipv4
neighbor 10.4.6.6 default-originate
add ipv6
neighbor FC00:10:4:6::6 default-originate
#R5
router bgp 65000
add ipv4
neighbor 10.5.6.6 default-originate
add ipv6
neighbor FC00:10:5:6::6 default-originate
#R6
ip prefix-list V4_DEFAULT permit 0.0.0.0/0
ipv6 prefix-list V6_DEFAULT permit ::/0
!
ip prefix-list V4_ADVERTISE permit 192.0.2.6/32
ipv6 prefix-list V6_ADVERTISE permit 2001:db8::6/128
!
ip community-list standard R4_DEFAULT permit 65006:4
!
route-map R4_IN
set community 65006:4
!
route-map V4_DEFAULT_VIA_R4
match ip addr prefix V4_DEFAULT
match community R4_DEFAULT
!
route-map V6_DEFAULT_VIA_R4
match ipv6 addr prefix V6_DEFAULT
match community R4_DEFAULT
!
route-map V4_ADVERTISE
match ip addr prefix V4_ADVERTISE
!
route-map V6_ADVERTISE
match ipv6 addr prefix V6_ADVERTISE
!
router bgp 65006
add ipv4
neighbor 10.4.6.4 route-map R4_IN in
neighbor 10.5.6.5 advertise-map V4_ADVERTISE non-exist-map V4_DEFAULT_VIA_R4
add ipv6
neighbor fc00:10:4:6::4 route-map R4_IN in
neighbor fc00:10:5:6::5 advertise-map V6_ADVERTISE non-exist-map V6_DEFAULT_VIA_R4
Explanation
This is quite a configuration intensive task. R6 must use prefix lists to identify the default routes and the local routes to advertise to R5. These must also belong to a route-map. Additionally, we need to match only R4’s default route. We cannot use a nexthop match for this. Instead, we assign a community to all routes received from R4, and match on this community. (Besides the prefix itself, you can only match on the AS_PATH and community).
Pay attention to the syntax to achieve the desired functionality. The router will only advertise 192.0.2.6/32 if a 0.0.0.0/0 route with community 65006:4 does not exist in the BGP RIB.
ip prefix-list V4_DEFAULT permit 0.0.0.0/0
!
ip prefix-list V4_ADVERTISE permit 192.0.2.6/32
!
ip community-list standard R4_DEFAULT permit 65006:4
!
route-map V4_DEFAULT_VIA_R4
match ip addr prefix V4_DEFAULT
match community R4_DEFAULT
!
route-map V4_ADVERTISE
match ip addr prefix V4_ADVERTISE
!
router bgp 65006
add ipv4
neighbor 10.5.6.5 advertise-map V4_ADVERTISE non-exist-map V4_DEFAULT_VIA_R4
Verification
When the defaults from R4 exist, R6 is withdrawing its local prefixes from R5.

Next, on R4 we remove the default origination for both address-families.
#R4
router bgp 65000
add ipv4
no neighbor 10.4.6.6 default-originate
add ipv6
no neighbor FC00:10:4:6::6 default-originate
!
do clear ip bgp * soft out
do clear bgp ipv6 uni * soft out
On R6 we debug IPv4 and IPv6 unicast updates. We see that the default routes have been withdrawn. In response, the BGP scanner on R6 changes the condition of the route-maps to Advertise. As a note, the bgp scan timer was lowered for IPv4 but not IPv6, which is why the IPv6 change takes so much longer. (If you are using this in production, you likely want to lower the scan timer as much as possible to reduce the outage interval).

Once the defaults via R4 are lost, R6 advertises its local prefixes to R5 again. If these defaults are learned later, R6 withdraws these.
Besides the non-exist-map, there is also the option for an exist-map. With a non-exist-map, the prefix is only advertised if the route-map condition is not met. With the exist-map, the prefix is only advertised when the route-map condition is met.
Last updated