What is conditional advertisement and why to use it?
Normally, routes are propagated regardless of the existence of a different path. The BGP conditional advertisement feature uses the non-exist-map and the advertise-map keywords of the neighbor advertise-map command in order to track routes by the route prefix. If a route prefix is not present in output of the non-exist-map command, then the route specified by the advertise-map command is announced. This feature is useful for multihomed networks, in which some prefixes are advertised to one of the providers only if information from the other provider is not present (this indicates a failure in the peering session or partial reachability).
In the example below we will configure one router but I have staged four additional Internet routers and two computer devices for testing purposes. The configuration of R1 must prefer the primary service provider ISP1 at all times and not become a transit router on the Internet. In the event the primary ISP network becomes unreachable BGP must failover to the backup service provider, ISP2. At that time R1 must advertise the 126.96.36.199/30 address space. If the primary service provider's network is stable the 188.8.131.52/30 address space must not be advertised to the backup service provider.
Steps to conditional advertisement
Step 1: Configure all applicable router interfaces.
R1(config)#interface FastEthernet0/0 R1(config-if)#ip address 184.108.40.206 255.255.255.252 ! R1(config)#interface FastEthernet0/1 R1(config-if)#ip address 220.127.116.11 255.255.255.252 ! R1(config)#interface FastEthernet1/0 R1(config-if)#ip address 18.104.22.168 255.255.255.252
Step 2: Enable a BGP routing process with each router having a unique AS number, enable BGP routing on all applicable IP networks, and configure static neighbors.
R1(config)#router bgp 101 R1(config-router)#bgp log-neighbor-changes R1(config-router)#network 22.214.171.124 mask 255.255.255.252 R1(config-router)#network 126.96.36.199 mask 255.255.255.252 R1(config-router)#network 188.8.131.52 mask 255.255.255.252 R1(config-router)#neighbor 184.108.40.206 remote-as 102 R1(config-router)#neighbor 220.127.116.11 remote-as 103
Step 3: Configure a higher local preference for routes from the neighbor R3 over the primary ISP.
R1(config)#route-map LOCALPREF permit 10 R1(config-route-map)#set local-preference 500 R1(config-route-map)#router bgp 101 R1(config-router)#neighbor 18.104.22.168 route-map LOCALPREF in
Step 4: Configure a distribute list so only our networks are advertised and our router does not become a transit router.
R1(config)#router bgp 101 R1(config-router)#neighbor 22.214.171.124 distribute-list 1 out R1(config-router)#neighbor 126.96.36.199 distribute-list 1 out ! R1(config)#access-list 1 permit 188.8.131.52 0.0.0.3
Step 5: Configure a prefix-list, community-list and route-map to only advertise the 184.108.40.206/30 address space when 220.127.116.11/30 is unreachable from a BGP perspective.
R1(config)#ip prefix-list PL-MY-NETWORK seq 5 permit 18.104.22.168/30 R1(config)#ip prefix-list PL-ISP1-NETWORK seq 5 permit 22.214.171.124/30 ! R1(config)#ip community-list 1 permit 104:103 ! R1(config)#route-map RM-AS104 permit 10 R1(config-route-map)#match community 1 R1(config-route-map)#match ip address prefix-list PL-ISP1-NETWORK ! R1(config)#route-map RM-TO-AS102 permit 10 R1(config-route-map)#match ip address prefix-list PL-MY-NETWORK ! R1(config)#router bgp 101 R1(config-router)#neighbor 126.96.36.199 advertise-map RM-TO-AS102 non-exist-map RM-AS104 R1(config-router)#neighbor 188.8.131.52 route-map set_community in ! R1(config)#route-map set_community permit 10 R1(config-route-map)#set community 104:103
Verify the configuration
Now that the configuration is finished lets verify our neighbors and routes. Using the show ip bgp summary and show ip route commands you can verify the remote routers to which your router has formed and adjacency and verify the expected routes are being advertised. Use the ping command to verify connectivity. Upon reviewing the routing table on R1 we can see ISP was the preferred path for all networks more than 1 hop away.
On R3 if we review the routing table we will see 184.108.40.206/30 is advertised only out of the ISP1 network.
Lastly, let's test failover. If we simulate a link failure between R1 and R3 the 220.127.116.11/30 network will become unavailable. After a period of time BGP will remove the network from the routing table and advertise the 18.104.22.168/30 network to R2. If we bring the link between R1 and R3 back up R1 will cease advertising 22.214.171.124/30 to R2 and ISP1 will be the preferred path once again.