Tags:acl Cisco ios ip-policy route-map router
Cisco routers running Cisco IOS supports pased based IP Routing which can route packets based on a set IP Policy exiting an Interface.
Policy based routing in Cisco ROuters can be performed by using "route-map" and then applying as a policy to the interface of the IP Packets.
The route-map has a list of "match" and "set" commands where match defines the criteria under which the policy routing is performed (say, match a destination IP or a standard or Extended ACL) and set defines the actions to perform when match criteris met (say, set next hop).
In this example, I change the routing to a particular network only from a particular subnet which is defined in a standard ACL. This ACL is then matched in a route-map and applied as an IP policy for routing change for the change in routing behaviour.
Create Standard ACL
From the global configuration mode, create an ACL to permit source network 10.1.1.0/24
ciscorouter# conf term
ciscorouter(config)# access-list 10 permit 10.1.1.0 0.0.0.255
That creates a new ACL "10" with a permit for 10.1.1.0/24 network.
Define a route-map with "match" conditions and "set" actions.
ciscorouter(config)# route-map SetNextHop permit 10
ciscorouter(config-route-map)# match ip address 10
ciscorouter(config-route-map)# set ip next-hop 192.168.0.1
That creates a route-map called "SetNextHop" and matches the ACL 10 where the source network for which the route-map should be actioned. I've set the action to be taken when the source network matches to set the next hop router as 192.168.0.1
Apply Policy Route-map to interface
This route-map is now applied to the interface (fa0/0)
ciscorouter(config)# interface fa0/0
ciscorouter(config-if)# ip policy route-map SetNextHop
Test for yourself. For source network 10.1.1.0/24, the nexthop IP is set as 192.168.0.1 (Router B) where every other source networks are router as specified by the static/dynamic routes (in our example through Router A)