Using Policy-Based Routing to Route Based on Source Address


You want to use different network links depending on the source address.


Policy-based routing allows you to configure special routing rules beyond the normal IP routing table. One common application is to route packets based on the IP source address rather than the destination address:

Router#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#access-list 1 permit
Router(config)#access-list 2 permit
Router(config)#interface Ethernet0
Router(config-if)#ip address
Router(config-if)#ip policy route-map Engineers
Router(config-if)#ip route-cache policy
Router(config)#route-map Engineers permit 10
Router(config-route-map)#match ip address 1
Router(config-route-map)#set ip next-hop
Router(config)#route-map Engineers permit 20
Router(config-route-map)#match ip address 2
Router(config-route-map)#set interface Ethernet1


This configuration example defines a special routing policy for a group of users defined by the route map called “Engineers.” This name is arbitrary, and we recommend that you choose names for your route maps that are meaningful in your organization. This example applies the route map to all of the packets received on the interface Ethernet0. This might be required because these users ...

Get Cisco IOS Cookbook, 2nd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.