By default, a BGP speaker advertises the best routes in its routing table to its peers. However, in some circumstances, you might prefer that some routes be advertised to a peer or peer group only when another route is in the BGP routing table, or only when that route is not in the routing table. BGP conditional advertisement enables you to control route advertisement without having to rely on only the best routes.
For example, in a multi-homed network, you might want to advertise certain prefixes to one of the providers when a failure occurs in the peering session with a different provider, or when there is only partial reachability to that peer.
In other cases, the advertisement to a peer of certain routes might be useful only in the event that some other routes are present in the BGP routing table.
You can use the neighbor advertise-map command with route maps to configure conditional advertisement of BGP routes to a peer or peer group within an address family. BGP conditional advertisement does not create routes. The routes specified by the route map in the neighbor advertise-map command must already be present in the BGP routing table.
BGP conditional advertisement is supported in only the following address families:
![]() |
Note: For VPNv4 unicast and VPNv6 unicast address families, we recommend that you include a match extcommunity clause to match a route with a specific route target. However, conditional advertisement in these address families can sometimes result in unintended behaviors: advertisement of or based on an incorrect VPN route or a non-VPN route. |
BGP conditional advertisement is not supported in the following address families:
Use the exist-map keyword when you want a route advertised only when another route is present. The determining route must match the specified route map. If the route map you specify with the exist-map keyword references multiple routes, only one of those routes needs to be in the routing table to trigger the conditional advertisement.
Use the non-exist-map keyword when you want a route advertised only when another route is absent. The determining route must match the specified route map. If the route map you specify with the non-exist-map keyword references multiple routes, all of those routes must be absent to trigger the conditional advertisement.
You can optionally specify a sequence number for the advertise route map that matches the determining route. The sequence number specifies the order in which the advertise route maps are processed. It indicates the position the specified advertise route map has in the list of all advertise route maps that are configured for a particular neighbor within the same address family.
If you do not specify a sequence number, the position of the advertise route map is considered to be the sum of the current largest sequence number plus five. An advertise route map with a lower sequence number has a higher priority and is processed before one with a higher sequence number.
If the route matches more than one advertise route map, only the first matching advertise route map, based on the sequence, controls the advertisement of a BGP route.
You can configure a maximum of 50 advertise maps for a given peer or peer group in an address family. However, the name and sequence number for the advertise route map must be unique for each entry. BGP applies any policy specified by the advertise map to the conditionally advertised routes before outbound policy specified for the neighbor is applied.
The route maps referenced by the neighbor advertise-map command must include a match ip-address clause. You can also include additional match clauses. All match commands supported by existing outbound policies are supported. The additional clauses are useful when you want to match only on a specific route with a specific set of attributes. Only the permit keyword is acted on in a match clause. The deny keyword is ignored. Only exact matching of a prefix referenced by exist maps or non-exist maps is supported. Consequently a range specified by the ge or le keyword in the prefix list referenced by these route maps is ignored.
Clauses in a route map that include set commands or the match-set summary prefix-tree command are ignored. To change the attributes of conditionally advertised routes, you must use outbound routing policy.
If the contents of a referenced route map are changed, the new route map takes effect automatically.
neighbor advertise-map
- host1(config-router-af)#neighbor 192.168.2.2
advertise-map advertiseroutes exist-map
matchroute sequence 10