Example: Setting Metrics for Routes Forwarded on the Basis of Communities
This example shows how to set metrics for routes forwarded on the basis of communities.
Requirements
This example uses the following software and hardware components:
- JunosE Release 7.1.0 or higher-numbered releases
- E Series router (ERX7xx models, ERX14xx models, the ERX310 router, the E120 router, or the E320 router)
- ASIC-based line modules that support Fast Ethernet or Gigabit Ethernet
Overview
Consider the network structure shown in Figure 5. In this network, you can configure router Albany to set metrics for routes that it forwards to router Boston on the basis of the communities to which the routes belong. You can create community lists and filter the routes with a route map that matches on the community list.
Figure 5: Community Lists

Configuration
Step-by-Step Procedure
The following example demonstrates about configuring router Albany to set metrics for routes that it forwards to router Boston on the basis of the communities.
To configure router Albany to set metrics for routes:
- Configure the BGP routing process.host1(config)#router bgp 293
- Add entries to the BGP neighbor table.host1(config-router)#neighbor 10.5.5.2 remote-as 32 host1(config-router)#neighbor 10.2.2.1 remote-as 451 host1(config-router)#neighbor 10.2.2.4 remote-as 17
- Apply a route map to incoming or outgoing routes.host1(config-router)#neighbor 10.2.2.4 route-map commtrc out host1(config-router)#exit
- Specify route map 1 and configure route map match and
set clauses.host1(config)#route-map commtrc permit 1 host1(config-route-map)#match community 1 host1(config-route-map)#set metric 20 host1(config-route-map)#exit
- Specify route map 2 and configure route map match and
set clauses.host1(config)#route-map commtrc permit 2 host1(config-route-map)#match community 2 host1(config-route-map)#set metric 75 host1(config-route-map)#exit
- Specify route map 3 and configure route map match and
set clauses.host1(config)#route-map commtrc permit 3 host1(config-route-map)#match community 3 host1(config-route-map)#set metric 85 host1(config-route-map)#exit
- Create community lists for BGP and control access to it.host1(config)#ip community-list 1 permit 25 host1(config)#ip community-list 2 permit 62 host1(config)#ip community-list 3 permit internet
Results
Community list 1 comprises routes with a community of 25; their metric is set to 20. Community list 2 comprises routes with a community of 62; their metric is set to 75. Community 3 catches all remaining routes by matching the Internet community; their metric is set to 85.
Related Documentation
- Community List Overview
- Creating an IP Community List for BGP
- Defining the Conditions for Redistributing Routes Using a Route Map
- Configuring Set Clauses for a Route Map
- Configuring Match Clauses and Values for a Route Map
- Monitoring IP Protocols
- Monitoring the Routes Permitted by IP Community Lists
- Monitoring Route Map Details
- ip community-list
- match community
- neighbor remote-as
- neighbor route-map
- router bgp
- route-map
- set metric