Redirecting external IP to localhost

Hey folks.

I would like to know how you can redirect an external IP to localhost. Im trying to emulate the server for a simple program one of my friends coded in C++ (or something). It is basicly a login and register system, upon registering the program sends a HTTP request to the server (it requests a PHP file) with username & password parameters, if the username is not taken the server replies "1", if it is taken it replies "0".
I made a PHP file on my server with the same name, though it would only return "0".

So here is the deal, the program connects to a server that i dont have access to, nor do i have access to the program's source code and i can't change what IP the program connects to, so i will have to somehow forward the IP it connects to to my server's IP.


Noob Whisperer
Hello and welcome to the forums.
Assuming you're running a local web server that responds to HTTP requests on port 80 then, you should be able to adjust the hosts file to accomplish this. Something like, for example
TheIpAddressOfTheLocalWebServer TheUrlThatTheAppIsCalling

Last edited:
I tried that, it is used to redirect hostnames or domain names, e.g., and cant redirect IP addresses. My friend's program connects to an IP (obviously), i tried adding the hostname for the IP to my hosts file, but that didn't work either.

And yes, i am running a standard web/HTTP server that responds to port 80.


Noob Whisperer
Yep, that's correct redirects URLs to IP and won't work IP to IP.
It's been a long time since I messed with the "Route" command, you can google it and try, probably something like
Route Add IpAddressAppIsCalling mask
route add mask (or instead of the local host loopback try the actual IP address that the HTTP server is responding on)

I tried messing with the route command a little, i tried "route add mask" (i edited the parameters of course), though i get an error: "Rutetilføjelse mislykkedes: Forkert parameter" (in danish), roughly translated to english: "Route addition failed: Wrong parameter"


Last edited:


Noob Whisperer
Try dropping the last .255 from the final octet and see if that works. (
It may also be expecting an interface parameter in the case of multiple NICs and or a metric value in most case locally 1
Keep us posted.

I was messing around, typing random numbers into the metric thing. Sometimes it threw me a "Element not found" error, the rest of the times it threw me the "Wrong parameter". Could you show me an example or something? Im really confused about this metric thing..

Progress! (I think)

I added the IP to my route table (with this cmd: "route add <ip> <target>" ("<ip>" being my friend's IP and "<target>" my own IP, NOT But, now when i try to sign in using the program or request the file through my browser it fails to load it, even though my HTTP server is running and responds when i use localhost, internal or external IP.

Nobody can help? :(

Bump. I really need your help guys :/


New Member
Bump. I really need your help guys :/
Just found out: Either add a loopback device and assign it the desired IP address, or
maybe add a secondary ip address in the extended settings of your existing network device.
Both can go with netmask
The first option worked better for me (after some silly device driver issues at first).

See e.g.
redirection - How do I redirect a request for an IP to the loopback? - Super User
redirect an ip address to localhost - Page 2

This website is not affiliated, owned, or endorsed by Microsoft Corporation. It is a member of the Microsoft Partner Program.