You can combine route maps with prefix lists to filter the routes advertised to or received from a BGP peer and to set BGP attributes for specific routes.

  1. Create a prefix list to match the networks to be filtered.
  2. Permit the networks you want to allow to be advertised and deny all others.
  3. Apply the prefix list to the BGP neighbor, inbound or outbound.

Below , example shows a prefix list that permits only summary routes in the 192.168.0.0 network. All other routes are denied by default. The prefix list is then applied to BGP neighbor 10.0.0.1 outbound, so only these routes will be advertised to that peer:

ip prefix-list Summary permit 192.168.0.0/16 le 20

!

router bgp 65001

neighbor 10.0.0.1 prefix-list Summary out

To verify the results use the command 

show ip prefix-list

To clear the counters shown in that command, use the 

clear ip prefix-list 

You can also combine a prefix list with a route map to set attributes on the routes allowed in the prefix list. In the following example, prefix list INBlist is used. A route map sets the Med for those routes to 100 when they are advertised. It sets a Med of 200 for all other routes advertised. The route map is then applied to BGP neighbor 10.0.0.1 outbound:

route-map INB permit 10

match ip address prefix-list INBlist

set metric 100

route-map INB permit 20

set metric 200

!

router bgp 65001

neighbor 10.0.0.1 route-map INB out