IP Routing: Protocol-Independent Configuration Guide, Cisco IOS XE Release 3SE (Catalyst 3850 Switches)
Policy-Based Routing
Downloads: This chapterpdf (PDF - 123.0KB) The complete bookPDF (PDF - 559.0KB) | Feedback

Policy-Based Routing

Policy-Based Routing

Last Updated: May 29, 2012

The Policy-Based Routing feature is a process whereby a device puts packets through a route map before routing the packets. The route map determines which packets are routed to which device next. Policy-based routing is a more flexible mechanism for routing packets than destination routing.

Finding Feature Information

Your software release may not support all the features documented in this module. For the latest caveats and feature information, see Bug Search Tool and the release notes for your platform and software release. To find information about the features documented in this module, and to see a list of the releases in which each feature is supported, see the feature information table at the end of this module.

Use Cisco Feature Navigator to find information about platform support and Cisco software image support. To access Cisco Feature Navigator, go to www.cisco.com/go/cfn. An account on Cisco.com is not required.

Information About Policy-Based Routing

Policy-Based Routing

Policy-based routing is a process whereby the device puts packets through a route map before routing them. The route map determines which packets are routed to which device next. You might enable policy-based routing if you want certain packets to be routed some way other than the obvious shortest path. Possible applications for policy-based routing are to provide equal access, protocol-sensitive routing, source-sensitive routing, routing based on interactive versus batch traffic, and routing based on dedicated links. Policy-based routing is a more flexible mechanism for routing packets than destination routing.

To enable policy-based routing, you must identify which route map to use for policy-based routing and create the route map. The route map itself specifies the match criteria and the resulting action if all of the match clauses are met.

To enable policy-based routing on an interface, indicate which route map the device should use by using the ip policy route-map map-tag command in interface configuration mode. A packet arriving on the specified interface is subject to policy-based routing except when its destination IP address is the same as the IP address of the device's interface. This ip policy route-map command disables fast switching of all packets arriving on this interface.

To define the route map to be used for policy-based routing, use the route-map map-tag [permit | deny] [sequence-number] global configuration command.

To define the criteria by which packets are examined to learn if they will be policy-based routed, use either the match length minimum-length maximum-length command or the match ip address {access-list-number | access-list-name} [access-list-number | access-list-name] command or both in route map configuration mode. No match clause in the route map indicates all packets.

To display the cache entries in the policy route cache, use the show ip cache policy command.

Precedence Setting in the IP Header

The precedence setting in the IP header determines whether, during times of high traffic, the packets are treated with more or less precedence than other packets. By default, the Cisco software leaves this value untouched; the header remains with the precedence value that it had.

The precedence bits in the IP header can be set in the device when policy-based routing is enabled. When the packets containing those headers arrive at another device, the packets are ordered for transmission according to the precedence set, if the queueing feature is enabled. The device does not honor the precedence bits if queueing is not enabled; the packets are sent in FIFO order.

You can change the precedence setting, using either a number or name (the names came from RFC 791). You can enable other features that use the values in the set ip precedence route map configuration command to determine precedence. The table below lists the possible numbers and their corresponding name, from lowest to highest precedence.

Table 1 IP Precedence Values

Number

Name

0

routine

1

priority

2

immediate

3

flash

4

flash-override

5

critical

6

internet

7

network

The set commands can be used with each other. They are evaluated in the order shown in the previous table. A usable next hop implies an interface. Once the local device finds a next hop and a usable interface, it routes the packet.

Local Policy Routing

Packets that are generated by the device are not normally policy-routed. To enable local policy routing for such packets, indicate which route map the device should use by using the ip local policy route-map map-tag global configuration command. All packets originating on the device will then be subject to local policy routing.

Use the show ip local policy command to display the route map used for local policy routing, if one exists.

How to Configure Policy-Based Routing

Configuring Policy-Based Routing

SUMMARY STEPS

1.    enable

2.    configure terminal

3.    interface type number

4.    ip policy route-map map-tag

5.    exit

6.    route-map map-tag [permit | deny] [sequence-number]

7.   Enter one or both of the following commands:

  • match length
  • match ip address

8.   set ip next-hop {ip-address[...ip-address] | dynamic dhcp | encapsulate l3vpn profile-name | peer-address | recursive [global | vrf vrf-name] ip-address | verify-availability [ip-address sequence track track-object-number]}

9.   end


DETAILED STEPS
Step 1   enable


Example:
Device> enable

Enables privileged EXEC mode.

  • Enter your password if prompted.
Step 2   configure terminal


Example:
Device# configure terminal

Enters global configuration mode.

Step 3   interface type number


Example:
Device(config)# interface gigabitethernet 1/0/0

Configures an interface type and enters interface configuration mode.

Step 4   ip policy route-map map-tag


Example:
Device(config-if)# ip policy route-map equal-access

Identifies a route map to use for policy routing on an interface.

Step 5   exit


Example:
Device(config-if)# exit

Returns to global configuration mode.

Step 6   route-map map-tag [permit | deny] [sequence-number]


Example:
Device(config)# route-map equal-access permit 10

Defines the conditions for redistributing routes from one routing protocol into another routing protocol or enables policy-based routing and enters route-map configuration mode.

  • map-tag--A meaningful name for the route map.
  • permit--(Optional) If the match criteria are met for this route map, and the permit keyword is specified, the route is redistributed as controlled by the set actions. In the case of policy routing, the packet is policy routed.

    If the match criteria are not met, and the permit keyword is specified, the next route map with the same map tag is tested. If a route passes none of the match criteria for the set of route maps sharing the same name, it is not redistributed by that set.

  • deny--(Optional) If the match criteria are met for the route map and the deny keyword is specified, the route is not redistributed. In the case of policy routing, the packet is not policy routed, and no further route maps sharing the same map tag name will be examined. If the packet is not policy routed, the normal forwarding algorithm is used.
  • sequence-number--(Optional) Number that indicates the position a new route map will have in the list of route maps already configured with the same name. If used with the no form of this command, the position of the route map configure terminal should be deleted.
Step 7   Enter one or both of the following commands:
  • match length
  • match ip address


Example:
Device(config-route-map)# match ip address 1

Define the criteria by which packets are examined to learn if they will be policy-based routed.

Step 8   set ip next-hop {ip-address[...ip-address] | dynamic dhcp | encapsulate l3vpn profile-name | peer-address | recursive [global | vrf vrf-name] ip-address | verify-availability [ip-address sequence track track-object-number]}


Example:
Device(config-route-map)# set ip next-hop 172.16.6.6

Specifies where to output packets that pass a match clause of a route map for policy routing.

Step 9   end


Example:
Device(config-route-map)# end

Exits route-map configuration mode and returns to privileged EXEC mode.


Configuration Examples for Policy-Based Routing

Example: Policy-Based Routing

The following example provides two sources with equal access to two different service providers. Packets that arrive on asynchronous interface 1/0/0 from the source 10.1.1.1 are sent to the device at 172.16.6.6 if the device has no explicit route for the destination of the packet. Packets that arrive from the source 172.17.2.2 are sent to the device at 192.168.7.7 if the device has no explicit route for the destination of the packet. All other packets for which the device has no explicit route to the destination are discarded.

Device(config)# access-list 1 permit ip 10.1.1.1 
Device(config)# access-list 2 permit ip 172.17.2.2 
Device(config)# interface async 1/0/0 
Device(config-if)# ip policy route-map equal-access 
Device(config-if)# exit 
Device(config)# route-map equal-access permit 10 
Device(config-route-map)# match ip address 1 
Device(config-route-map)# set ip default next-hop 172.16.6.6 
Device(config-route-map)# exit 
Device(config)# route-map equal-access permit 20 
Device(config-route-map)# match ip address 2 
Device(config-route-map)# set ip default next-hop 192.168.7.7 
Device(config-route-map)# exit 
Device(config)# route-map equal-access permit 30 
Device(config-route-map)# set default interface null 0 
Device(config-route-map)# exit 

Example: Policy Routing with Cisco Express Forwarding

The following example shows how to configure policy routing with Cisco Express Forwarding. The route is configured to verify that the next hop 10.0.0.8 of the route map named test is a Cisco Discovery Protocol neighbor before the device tries to policy-route to it.

Device(config)# ip cef 
Device(config)# interface GigabitEthernet 0/0/1 
Device(config-if)# ip route-cache flow 
Device(config-if)# ip policy route-map test 
Device(config-if)# exit 
Device(config)# route-map test permit 10 
Device(config-route-map)# match ip address 1 
Device(config-route-map)# set ip precedence priority 
Device(config-route-map)# set ip next-hop 10.0.0.8 
Device(config-route-map)# set ip next-hop verify-availability 
Device(config-route-map)# exit 
Device(config)# route-map test permit 20 
Device(config-route-map)# match ip address 101 
Device(config-route-map)# set interface Ethernet 0/0/3 
Device(config-route-map)# set ip tos max-throughput 
Device(config-route-map)# exit
 

Example: Policy-Based Routing

The following example shows how packets with a Level 3 length of 3 to 50 bytes are output to the router at IP address 10.14.2.2:

interface serial 0
 ip policy route-map thataway
!
route-map thataway
 match length 3 50
 set ip next-hop 10.14.2.2
 

Additional References

Related Documents

Related Topic

Document Title

Cisco IOS commands

Cisco IOS Master Command List, All Releases

IP routing protocol-independent commands

Cisco IOS IP Routing: Protocol-Independent Command Reference

Technical Assistance

Description

Link

The Cisco Support and Documentation website provides online resources to download documentation, software, and tools. Use these resources to install and configure the software and to troubleshoot and resolve technical issues with Cisco products and technologies. Access to most tools on the Cisco Support and Documentation website requires a Cisco.com user ID and password.

http://www.cisco.com/cisco/web/support/index.html

Feature Information for Policy-Based Routing

The following table provides release information about the feature or features described in this module. This table lists only the software release that introduced support for a given feature in a given software release train. Unless noted otherwise, subsequent releases of that software release train also support that feature.

Use Cisco Feature Navigator to find information about platform support and Cisco software image support. To access Cisco Feature Navigator, go to www.cisco.com/go/cfn. An account on Cisco.com is not required.

Table 2 Feature Information for Policy-Based Routing
Feature Name Releases Feature Information

Policy-Based Routing

11.0

Cisco IOS XE Release 2.2

The Policy-Based Routing feature is a process whereby a device puts packets through a route map before routing the packets. The route map determines which packets are routed to which device next. Policy-Based Routing introduces a more flexible mechanism for routing packets than destination routing.

The following command was introduced or modified: ip policy route-map.

Cisco and the Cisco logo are trademarks or registered trademarks of Cisco and/or its affiliates in the U.S. and other countries. To view a list of Cisco trademarks, go to this URL: www.cisco.com/go/trademarks. Third-party trademarks mentioned are the property of their respective owners. The use of the word partner does not imply a partnership relationship between Cisco and any other company. (1110R)

Any Internet Protocol (IP) addresses and phone numbers used in this document are not intended to be actual addresses and phone numbers. Any examples, command display output, network topology diagrams, and other figures included in the document are shown for illustrative purposes only. Any use of actual IP addresses or phone numbers in illustrative content is unintentional and coincidental.

© 1998-2013 Cisco Systems, Inc. All rights reserved.