I got an application (no source code) calling a server (hard coded IP) and expecting an answer before starting (a kind of login).

Cause the server is down half of the time, I want to create a dummy server which will emulate the behavior of the official server.

My problem:

How can I redirect the traffic to my local machine?

I want all the request send to IP w.x.y.z to be re-routed to localhost (where my dummy server is running)

More info:

  • my dummy server is an apache/php solution.
  • I tried to edit the hard coded IP in the application with an hex editor, but some checksum fail when I start the application.
  • cause the IP is hard coded in the application, I cannot use the hosts file.
  • I'm running win xp.

related: How to redirect traffic to one IP to a different IP on Windows Server 2008

3 Answers 3


This would be a total hack, but you could try assigning the IP of the server in question as an additional IP on you local interface, instructions here

  • This looks great !. but I cannot try it now, (my internet is down, I'm tethering on 3G..). I give you some feedback at the end of next week.
    – Loda
    Aug 20, 2010 at 8:41
  • 1
    This really rocks ! working great, very easy solution. thanks !
    – Loda
    Aug 20, 2010 at 14:23
  • Sweet, glad to hear it :) Aug 20, 2010 at 16:40
  • 2
    Precision: Adding a 2sd IP to my NIC got a side effect; all IP in the same external subred are redirected to my NIC. ie: when adding IP, IP is not reachable anymore. This is caused by the route and the route Workaround: add route -> normal gateway.
    – Loda
    Aug 23, 2010 at 10:02
  • the link is broken
    – danilo
    Aug 24, 2019 at 21:03

Well, you could try the following:

Set up a specific route for that IP address, which will use the dummy server as gateway, like this:

route add -host w.x.y.z/32 gw dummy-server-ip

For this you will need either access to the main router for your network, or you have to do it on the machine that is sending the requests. This effectively sends the TCP packets with the w.x.y.z IP address to the MAC address of the dummy-server. So now you need to make sure the dummy server knows what to do with them.

Then add the w.x.y.z IP address as a secondary address to the dummy server.
Finally update the apache config on the dummy server to ensure it also listens on the w.x.y.z address, and make sure that the vhost on the dummy server accepts incoming requests for both the IP address and the domain name.

Please note that this will only work if there are no other routers between the requesting machine and the dummy-server. And if there are any firewalls involved, they also need updating.

  • Thanks for the answer it's look exactly like what I want to do. but, I got problem implementing it. I will prefer to not touch the router, also because, the solution should be exclusive for my machine. The command you put me as an example does not work on my win xp. I also tried "route add w.x.y.z" without success. I do not have firewall/router between the application and the dummy server. they both run on the same machine. (But, I do have a software firewall:kaspersky) I will really appreciate some help about how to set this route.
    – Loda
    Aug 19, 2010 at 9:08
  • 1
    There is a route command available for Windows: route ADD w.x.y.z MASK This will point the route back onto your own machine. You might have to open the firewall for incoming requests on the w.x.y.z address.
    – wolfgangsz
    Aug 19, 2010 at 14:53
  • I did try to add a route using this command with no success. don't know why.
    – Loda
    Aug 20, 2010 at 14:22
  • "route add mask" The error message say : "error adding the route: incorrect parameter" (translated from ES)
    – Loda
    Aug 20, 2010 at 14:26
  • Hmm, maybe you need to replace with the actual LAN IP address of that interface. I have never tried anything like this before, so there is a little guesswork involved.
    – wolfgangsz
    Aug 20, 2010 at 17:16

You could probably bang something together with iptables. Here's something I once used but am no longer doing to give you a toehold:

-A PREROUTING -d -i eth0 -p tcp -m tcp --dport 25 -j DNAT --to

NB: I did this a long time ago, there may be mistakes in there

The only thing I see that might be an issue is that it's specific to the interface. I think that the eth0 is only for the inbound part, so using an ip on the lo interface ( as the target might still work...

  • 2
    That'd be a great answer...but he's running Windows XP.
    – Jason Berg
    Aug 18, 2010 at 14:57
  • Doh! I think I saw "apache/php" and stopped reading. Even after you pointed it out I scanned three times before I saw it. Oh well, I'll leave it, maybe it'll help someone somewhere somewhen.
    – jj33
    Aug 18, 2010 at 15:15
  • I'm thinkering with Vagrant, busybox and iptables to create a selective VPN. I want to be able to tell my system that only a few known IP addresses belongs to the VPN so traffic to somewhere else won't go through the VPN. My idea is to use a very lightweight Linux as busybox to connect to the VPN, and then using iptables, or hosts file, or something similar, redirect the requests of the known IP addresses to the guest Vagrant VM so that it will handle the VPN. This iptables rules might give me some help :) May 17, 2016 at 9:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .