Example: Applying Access Lists Using a Route Map to Filter Routes

This example explains how to apply access lists using a route map to filter routes.

Requirements

This example uses the following software and hardware components:

Overview

You can use a route map instead of the neighbor filter-list command to apply access lists for filtering routes.

In Figure 4, a route map is used to determine the weight for routes learned by router Chicago.

Figure 4: Route Map Filtering

Route Map Filtering

Access list 1 permits any route whose AS-path attribute includes 32 or 837. This condition permits routes that originate in (or pass through from elsewhere) AS 32 or AS 837. When these routes are advertised through AS 451 and AS 17 to router Chicago, instance 1 of route map 1 matches such routes and sets their weight to 25, overriding the neighbor weight set for updates received from 10.2.2.4.

Access list 2 permits any route whose AS-path attribute indicates that it originates in AS 74. When these routes are advertised through AS 837 and AS 32 to router Chicago, instance 1 of route map 2 matches such routes and sets their weight to 175, overriding the neighbor weight set for updates received from 10.5.5.2.

Configuration

Step-by-Step Procedure

The following example demonstrates about using route map instead of the neighbor filter-list command to apply access lists for filtering routes.

To apply access lists for filtering routes:

  1. Configure the BGP routing process.
    host1(config)#router bgp 293
  2. Configure a BGP speaker.
    host1(config-router)#network 192.168.5.0 mask 255.255.255.0
  3. Add entries to the BGP neighbor table.
    host1(config-router)#neighbor 10.2.2.4 remote-as 17 host1(config-router)#neighbor 10.5.5.2 remote-as 32
  4. Assign a weight to a neighbor connection.
    host1(config-router)#neighbor 10.2.2.4 weight 150 host1(config-router)#neighbor 10.5.5.2 weight 50
  5. Apply a route map to incoming or outgoing routes.
    host1(config-router)#neighbor 10.2.2.4 route-map 1 in host1(config-router)#neighbor 10.5.5.2 route-map 2 in host1(config-router)#exit
  6. Specify route map 1 and configure the route map match and set clauses.
    host1(config)#route-map 1 permit 1 host1(config-route-map)#match as-path 1 host1(config-route-map)#set weight 25 host1(config-route-map)#exit
  7. Specify route map 2 and configure the route map match and set clauses.
    host1(config)#route-map 2 permit 1 host1(config-route-map)#match as-path 2 host1(config-route-map)#set weight 175 host1(config-route-map)#exit
  8. Define BGP-related access lists.

    host1(config)#ip as-path access-list 1 permit [ 32 837 ] host1(config)#ip as-path access-list 2 permit [ 74 ] host1(config-route-map)#exit

Results

The result of this configuration is that router Chicago prefers routes learned through router Boston (weight 150) over routes learned through router NY (weight 50), except that:

Related Documentation