BGP Conditional Advertisements using Advertise Maps

I've been playing around with some BGP configuration lately and have come across advertise maps before but never really looked into them. A BGP advertise map is basically a way of telling the router, if this route exists or does not exist, then advertise these routes. 

The reason I started to dig into these a bit more was a) because it's something I haven't looked at previously and i'm a curious person and b) because when I came across these at work, I found that they weren't configured correctly and therefore were not working. It took a bit of reading and playing around but eventually I managed to get my head around it and get it to work so decided to document it and write about it. Below is the network topology for this post. 

 

 

In this scenario, I have an edge router (R1) with two eBGP peers (R2 and R3). All routers advertise their Loopback address's to each other and R1 also has a subnet 192.168.10.0/24 attached that is also advertised via BGP. To show how advertise maps work, R3 is an eBGP peer that I only want to advertise the 192.168.10.0/24 range to if I lose the default route that I'm receiving from the BGP peer R2. With advertise maps, you can specify either an exist map, or a not exist map. As their name suggests, one option looks at the RIB and determines if the route exists and if it does, then it advertises the specified routes and the other looks to see if a route doesn't exist to determine if the advertisement should be sent or not. 

Let's first take a look at the BGP RIB on R1, R2, and R3.

R1#sh bgp ipv4 un
BGP table version is 8, local router ID is 1.1.1.1
     Network          Next Hop            Metric LocPrf Weight Path
 *>  0.0.0.0          10.1.12.2                              0 2 i
 *>  1.1.1.0/24       0.0.0.0                  0         32768 i
 *>  2.2.2.0/24       10.1.12.2                0             0 2 i
 *>  3.3.3.0/24       10.1.13.3                0             0 3 i
 *   10.1.12.0/24     10.1.12.2                0             0 2 i
 *>                   0.0.0.0                  0         32768 i
 *   10.1.13.0/24     10.1.13.3                0             0 3 i
 *>                   0.0.0.0                  0         32768 i
 *>  192.168.10.0     0.0.0.0                  0         32768 i
R1#

R2#sh bgp ipv4 un
BGP table version is 9, local router ID is 2.2.2.2
     Network          Next Hop            Metric LocPrf Weight Path
     0.0.0.0          0.0.0.0                                0 i
 *>  1.1.1.0/24       10.1.12.1                0             0 1 i
 *>  2.2.2.0/24       0.0.0.0                  0         32768 i
 *>  3.3.3.0/24       10.1.12.1                              0 1 3 i
 *>  10.1.12.0/24     0.0.0.0                  0         32768 i
 *                    10.1.12.1                0             0 1 i
 *>  10.1.13.0/24     10.1.12.1                0             0 1 i
 *>  192.168.10.0     10.1.12.1                0             0 1 i
R2#

R3#sh bgp ipv4 un
BGP table version is 9, local router ID is 3.3.3.3
     Network          Next Hop            Metric LocPrf Weight Path
 *>  0.0.0.0          10.1.13.1                              0 1 2 i
 *>  1.1.1.0/24       10.1.13.1                0             0 1 i
 *>  2.2.2.0/24       10.1.13.1                              0 1 2 i
 *>  3.3.3.0/24       0.0.0.0                  0         32768 i
 *>  10.1.12.0/24     10.1.13.1                0             0 1 i
 *>  10.1.13.0/24     0.0.0.0                  0         32768 i
 *                    10.1.13.1                0             0 1 i
 *>  192.168.10.0     10.1.13.1                0             0 1 i
R3#

As you can see all routers are currently advertising all Loopback ranges to each other and R1 and R3 is also receiving a default route from R2. R1 is currently configure to advertise the 192.168.10.0/24 range to both R2, and R3 BGP peers as well. 

The default route received from R2 in this scenario is what will be used in the conditional advertisement. The route-map will be configured to ensure that the default route from R2 exists, and is in the RIB. If the default route is there, R1 will not advertise the 192.168.10.0/24 subnet to R2. If the default route from R2 goes away, then the 192.168.10.0/24 subnet will be advertised to R3. 

Once you have your advertise maps worked out, you will need to create the prefix lists and route-maps. You will need to create a prefix list for the exist/not-exist map, another for the routes to be advertised, and a third for the outbound route-map to the BGP peer (or you can just have an open permit any route-map). In this scenario, the not-exist map prefix list will be a default route prefix list and the advertise prefix list will contain the 192.168.10.0/24 prefix. 

ip prefix-list DEFAULT seq 10 permit 0.0.0.0/0

ip prefix-list COND_ADV seq 10 permit 192.168.10.0/24

With the two prefixes created, you now need to create the route-maps. You will need to create two route-maps as well, one for the not-exist map, and one for the advertise map. 

route-map DEFAULT permit 10
match ip address prefix-list DEFAULT

route-map COND_ADV permit 10
match ip address prefix-list COND_ADV

Okay, that's all you need for the advertise map. However, you will also need to configure your outbound route-map. This is the bit that when I first looked at advertise maps, I had some issues with because it was broken in the examples I was looking at. The thing to remember with the outbound route-map is that you not only need to specify the routes that you always want to advertise to the BGP peer, but you also need to specify the advertise-map routes. The reason for this is the order of processing of route-maps. The router will look at the advertise map first and the outbound route-map second. This means that regardless of what your advertise map is configured with, if the routes aren't in the outbound route-map, they won't be advertised. So let's go ahead and configure the outbound prefix-list and route-map. 

ip prefix-list TO_R3 seq 10 permit 1.1.1.0/24
ip prefix-list TO_R3 seq 20 permit 192.168.10.0/24

route-map TO_R3 permit 10
match ip address prefix-list TO_R3

Okay now that I have all of my route-maps configured, it's time to apply them. Because I'm  wanting to conditionally advertise the 192.168.10.0/24 route to R3, that's the BGP peer that I need to apply the advertise-map statement to. 

conf t
router bgp 1
addr ipv4 uni
neighbo 10.1.13.3 advertise-map COND_ADV non-exist DEFAULT
neighb 10.1.13.3 route-map TO_R3 out

Note that I am using a non-exist map in this case as I only want the 192.168.10.0/24 subnet to be advertised to R3 if the default route from R2 goes away and also note, that i'm not allowing all of the other routes that are shown in the output of the original sh bgp ipv4 uni command. Now that the route-maps are all applied. Let's take another look at the BGP RIB on R3. 

R3#sh bgp ipv4 un
BGP table version is 15, local router ID is 3.3.3.3
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
              x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path
 *>  1.1.1.0/24       10.1.13.1                0             0 1 i
 *>  3.3.3.0/24       0.0.0.0                  0         32768 i
 *>  10.1.13.0/24     0.0.0.0                  0         32768 i
R3#

As you can see, I am no longer receiving the default route, or the 192.168.10.0/24 route. If you take a look at the output of the show bgp ipv4 un neighbor command on R1, you can see the status of the conditional advertisement is WITHDRAWN. 

R1#sh bgp ipv4 un neigh 10.1.13.3
BGP neighbor is 10.1.13.3,  remote AS 3, external link
  BGP version 4, remote router ID 3.3.3.3
  BGP state = Established, up for 02:12:59
  Last read 00:00:03, last write 00:00:07, hold time is 180, keepalive interval is 60 seconds
------ OMITTED FOR BREVITY ------
 For address family: IPv4 Unicast
  Session: 10.1.13.3
  BGP table version 10, neighbor version 10/0
  Output queue size : 0
  Index 3, Advertise bit 1
  3 update-group member
  Outbound path policy configured
  Route map for outgoing advertisements is TO_R3
  Condition-map DEFAULT, Advertise-map COND_ADV, status: Withdraw
  Slow-peer detection is disabled
  Slow-peer split-update-group dynamic is disabled
                                 Sent       Rcvd
------ OMITTED FOR BREVITY ------  
R1#

To test our conditional advertisement, Let's remove the default route from being advertised by R2. To do that, on R2 I'm just going to remove the neighbor 10.1.12.1 default-originate command. Once that's removed, it does take quite a while with default BGP timers etc but eventually I was able to see the default route disappear from R1, and the 192.168.10.0/24 route appear on R3. 

R1#sh bgp ipv4 un
BGP table version is 11, local router ID is 1.1.1.1

     Network          Next Hop            Metric LocPrf Weight Path
 *>  1.1.1.0/24       0.0.0.0                  0         32768 i
 *>  2.2.2.0/24       10.1.12.2                0             0 2 i
 *>  3.3.3.0/24       10.1.13.3                0             0 3 i
 *   10.1.12.0/24     10.1.12.2                0             0 2 i
 *>                   0.0.0.0                  0         32768 i
 *   10.1.13.0/24     10.1.13.3                0             0 3 i
 *>                   0.0.0.0                  0         32768 i
 *>  192.168.10.0     0.0.0.0                  0         32768 i
R1#


R3#sh bgp ipv4 un
BGP table version is 16, local router ID is 3.3.3.3

     Network          Next Hop            Metric LocPrf Weight Path
 *>  1.1.1.0/24       10.1.13.1                0             0 1 i
 *>  3.3.3.0/24       0.0.0.0                  0         32768 i
 *>  10.1.13.0/24     0.0.0.0                  0         32768 i
 *>  192.168.10.0     10.1.13.1                0             0 1 i
R3#

And once again, if you look at the output of the sh bgp ipv4 uni neighbor command on R1, you can see that this time the conditional advertisement status is Advertise.

R1#sh bgp ipv4 un neigh 10.1.13.3
BGP neighbor is 10.1.13.3,  remote AS 3, external link
  BGP version 4, remote router ID 3.3.3.3
  BGP state = Established, up for 02:19:08
  Last read 00:00:35, last write 00:00:13, hold time is 180, keepalive interval is 60 seconds
------ OMITTED FOR BREVITY ------
 For address family: IPv4 Unicast
  Session: 10.1.13.3
  BGP table version 12, neighbor version 12/0
  Output queue size : 0
  Index 3, Advertise bit 1
  3 update-group member
  Inbound soft reconfiguration allowed
  Outbound path policy configured
  Route map for outgoing advertisements is TO_R3
  Condition-map DEFAULT, Advertise-map COND_ADV, status: Advertise
  Slow-peer detection is disabled
  Slow-peer split-update-group dynamic is disabled
                                 Sent       Rcvd
------ OMITTED FOR BREVITY ------
R1#

And that's it. The same works for an exist map. If I was to change the non-exist command to an exist command, we would see the 192.168.10.0/24 subnet only being advertised to R3 when the default route appears. 

conf t
router bgp 1
addr ipv4 uni
neighbo 10.1.13.3 advertise-map COND_ADV exist-map DEFAULT

Now as you can see once I enter the exist map command instead of non-exist, and wait a couple of minutes for BGP to catch up, the 192.168.10.0/24 subnet is no longer advertised to R3, and the output of the sh bgp ipv4 uni neigh command shows the status as Withdrawn. 

R3#sh bgp ipv4 un
BGP table version is 6, local router ID is 3.3.3.3

     Network          Next Hop            Metric LocPrf Weight Path
 *>  1.1.1.0/24       10.1.13.1                0             0 1 i
 *>  3.3.3.0/24       0.0.0.0                  0         32768 i
 *>  10.1.13.0/24     0.0.0.

R3#

R1#sh bgp ipv4 uni neigh 10.1.13.3
BGP neighbor is 10.1.13.3,  remote AS 3, external link
  BGP version 4, remote router ID 3.3.3.3
  BGP state = Established, up for 00:08:23
  Last read 00:00:43, last write 00:00:32, hold time is 180, keepalive interval is 60 seconds
------ OMITTED FOR BREVITY ------
 For address family: IPv4 Unicast
  Session: 10.1.13.3
  BGP table version 11, neighbor version 11/0
  Output queue size : 0
  Index 2, Advertise bit 1
  2 update-group member
  Inbound soft reconfiguration allowed
  Outbound path policy configured
  Route map for outgoing advertisements is TO_R3
  Condition-map DEFAULT, Advertise-map COND_ADV, status: Withdraw
------ OMITTED FOR BREVITY ------
R1#

If I now introduce the default route from R2 again, we should see the 192.168.10.0/24 route show up in the R3 BGP table.

R1#sh bgp ipv4 un
BGP table version is 13, local router ID is 1.1.1.1
     Network          Next Hop            Metric LocPrf Weight Path
 *>  0.0.0.0          10.1.12.2                              0 2 i
 *>  1.1.1.0/24       0.0.0.0                  0         32768 i
 *>  2.2.2.0/24       10.1.12.2                0             0 2 i
 *>  3.3.3.0/24       10.1.13.3                0             0 3 i
 *>  10.1.12.0/24     0.0.0.0                  0         32768 i
 *                    10.1.12.2                0             0 2 i
 *>  10.1.13.0/24     0.0.0.0                  0         32768 i
 *                    10.1.13.3                0             0 3 i
 *>  192.168.10.0     0.0.0.0                  0         32768 i
R1#

R3#sh bgp ipv4 un
BGP table version is 7, local router ID is 3.3.3.3
     Network          Next Hop            Metric LocPrf Weight Path
 *>  1.1.1.0/24       10.1.13.1                0             0 1 i
 *>  3.3.3.0/24       0.0.0.0                  0         32768 i
 *>  10.1.13.0/24     0.0.0.0                  0         32768 i
 *>  192.168.10.0     10.1.13.1                0             0 1 i
R3#


R1#sh bgp ipv4 uni neigh 10.1.13.3
BGP neighbor is 10.1.13.3,  remote AS 3, external link
  BGP version 4, remote router ID 3.3.3.3
  BGP state = Established, up for 00:11:35
  Last read 00:00:11, last write 00:00:26, hold time is 180, keepalive interval is 60 seconds
------ OMITTED FOR BREVITY ------
 For address family: IPv4 Unicast
  Session: 10.1.13.3
  BGP table version 13, neighbor version 13/0
  Output queue size : 0
  Index 2, Advertise bit 1
  2 update-group member
  Inbound soft reconfiguration allowed
  Outbound path policy configured
  Route map for outgoing advertisements is TO_R3
  Condition-map DEFAULT, Advertise-map COND_ADV, status: Advertise
------ OMITTED FOR BREVITY ------

R1#

Once again you can see the status of the conditional advertisement is now Advertise instead of Withdrawn. 

If you've noticed anything missing or have any issues with this post or just want to say Hi, please leave a comment.

Tags

Add new comment