Showing results for 
Search instead for 
Did you mean: 
Join Customer Connection to register!
Jim Mueller

Reroute traffic based upon source network?

I'm not sure if this is the best forum for this question, but I'll start here.

We moved a local web application to the cloud about 2 years ago. After it was moved, we were struggling with performance using the internet route so we ordered a 1G P2P circuit directly between out respective datacenters. After the equipment was upgraded at each datacenter, it was determined during testing that the P2P circuit performance was snappier than the public route. However, there were significantly fewer users testing the private circuit compared to the production web site.

In an effort to offer the best end user experience, management wants to know if we can define which offices/floors (each have their own subnet) use which route to the web application. They don't want to advertise both remote URLs and cause an influx of calls if one of the remote URLs is inaccessible. If either remote host went down, we'd want to make it as simple as possible to adjust the routing so that all clients temporarily used the remote host which was still up.

Local virtual host:
Remote host 1:, accessed via public internet
Remote host 2:, accessed via private P2P circuit

Sample logic: Client browses to If the source IP of the client is within a predefined list of networks, then re-route to remote host 1, else re-route to remote host 2. If the default route is down, use the other host instead.

Any ideas on whether this is possible, and if yes, specifics on how it could be implemented, are appreciated.

Thanks for you help.

Georg Pauwen
VIP Expert


I cannot really tell from your diagram if the two URLs are accessible through two different links. Either way, I have come up with a rudimentary EEM script that would route hosts from a specific subnet ( in this example) through one link by means of applying a route map on the outbound interface. If that link, which is tracked, is down, it would remove the route map and add a new default route.

It would look something like this:

4321#(config)#ip access-list extended 101
4321(config-ext-nacl)#permit ip any
4321(config)#route-map TO_PRIVATE_MAP
4321(config-route-map)#match ip address 101
4321(config-route-map)#set ip next-hop

ip route

ip sla 11
threshold 4000
frequency 6
ip sla schedule 11 life forever start-time now

track 11 ip sla 11
default-state up

event manager applet TO_PRIVATE_UP
event track 11 state up
action 1 cli command "enable"
action 2 cli command "conf t"
action 3 cli command "interface GigabitEthernet0/1"
action 4 cli command "ip policy route-map TO_PRIVATE_MAP"
action 5 cli command "end"

event manager applet TO_PRIVATE_DOWN
event track 11 state down
action 1 cli command "enable"
action 2 cli command "conf t"
action 3 cli command "no ip route"
action 4 cli command "ip route"
action 5 cli command "interface GigabitEthernet0/1"
action 6 cli command "no ip policy route-map TO_PRIVATE_MAP"
action 7 cli command "end"

Hi Georg,

Thank you for the sample script. The public URL would be accessible through the cloud at the bottom of the diagram. The private circuit doesn't happen to be on that diagram, but the local side of the fiber circuit terminates on a Cisco 4431 on port Gi0/1, and the 4431 (Gi0/2) connects to our core switch stack (Gi2/0/48).

I'm not convinced management's request is feasible. Let me add more detail.

A client would browse to an internal URL of our choice and advertised to everyone to use. Based upon the clients source network, a mechanism would default to rerouting the request to the remote public IP/URL (, or if the source network is in a specific list then it would reroute the request to the remote private IP/URL ( Ideally, it would fail over to the other remote IP/URL if one of them went down.

Even if we get the traffic to the correct remote IP/URL, what's going to rewrite the URL to the correct syntax? It's not going to help if they simply land on an IIS7 landing page instead of the login page. I think that is something that the vendor would need to address on their side?


we would need to combine the EEM script with a TCL script to call the specific URLs. I'll see what I can come up with...


would it be possible to distribute a batch file to users (and create a desktop icon that users can click to execute the batch file) ? The batch file would ping both websites, if one is not available, it would open the other one. The policy routing would take care of the routing and the failover.

Before going into the details of the batch file, would that be a feasible solution ?


here is the batch file I am thinking of. Basically, the internal URL is pinged,if it responds, it is opened, if not, the external URL is opened. The ping response would be taken care of by the policy routing...

@echo off
ping -n 1 ( >nul

start chrome
GOTO end

start chrome
GOTO end

Hi Georg,

While that process is technically feasible, we'd rather have them use central URL hosted on our intranet to access the remote application.

Ji-Won Park


What you are looking for is called Policy Based Routing, aka Source Based Routing.

The configuration can be different based on your software type and version.



Hi , As Suggested by others ..You should think of PBR but  is the url ip address are static or it will change dynamically.

Check below is the sample PBR configuration based on source ip address..

The following example illustrates how to route traffic from different sources to different places (next hops). Packets arriving from source are sent to the next hop at; packets arriving from source are sent to the next hop at 

access-list 1 permit ip
access-list 2 permit ip
interface fastethernet 3/1 
ip policy route-map Source 1
route-map Source 1 permit 10
match ip address 1
set ip next-hop
route-map Source 1 permit 20
match ip address 2
set ip next-hop

Hope it Helps..