Windows 7 Redirecting external IP to localhost

BHeart

New Member
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.
 
BHeart:
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
192.168.1.111 windows7forums.com
 
Last edited:
I tried that, it is used to redirect hostnames or domain names, e.g. google.com, 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.
 
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 255.255.255.255 127.0.0.1
route add 64.233.169.99 mask 255.255.255.255 127.0.0.1 (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 64.233.169.99 mask 255.255.255.255 127.0.0.1" (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"
 

Attachments

  • a2a33c92ce2516c4aed33eae720b2088.png
    a2a33c92ce2516c4aed33eae720b2088.png
    1.1 KB · Views: 838
Last edited:
Try dropping the last .255 from the final octet and see if that works. (255.255.255.0)
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 127.0.0.1)). 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.
 
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 255.255.255.255.
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
 
Back
Top