0

On a Windows machine, I would like to direct all outgoing network traffic destined for one host to another (not another IP address). So for example, all requests to host.acme.com must go to server.ajax.net or something like that.

What is the way to do this or what must I search for? (If I understood the correct terminology, it would make it a lot easier to search for).

(A little background on what I want to achieve: I want to set up something like UnoTelly just for myself on my machine, where requests to certain hosts are sent to an AWS Cloudfront server. For this, however, it does not suffice to resolve hostnames to different IP addresses; I must actually forward the traffic to a different host by its hostname).

2 Answers 2

1

The simplest way to do that is to use the machine's host file:

  1. Find out the IP address of the machine you want to redirect to
  2. Edit the c:\windows\system32\drivers\etc\hosts file (yes, there is no extension) with any text editor. You might need to start the editor with a high security token (run as administrator" if UAC is enabled
  3. Add a line to the host file that read:

1.2.3.4 host.acme.com

(where 1.2.3.4 is actually the IP address of your destination machine)

Save the file, and you're done. Note, however, that this will just change the IP address of the machine that you'll connect to when using the host.acme.com dns host name. It will not change anything in the content of these connections so if you're using a protocol like HTTP (or SSL) where the host name is embedded into the data, the target machine might not respond properly.

3
  • Hi, like I said in my question, I don't just need to change the IP address, I need to forward to another machine by hostname. Jun 5, 2013 at 15:12
  • just perform the name resolution in advance and then use that result. Your target machine isn't going to switch IP every 5 minutes.
    – Stephane
    Jun 5, 2013 at 15:29
  • No, but the target machine is on a shared host. So just forwarding to that IP address doesn't help. But thanks anyway. I found another post which says that you can't do routing to a hostname: serverfault.com/a/301984/118544. However, I think I may have the answer. I will try it out and post the results here. Jun 5, 2013 at 16:25
0

As the following answer points out, you cannot route to a host name: https://serverfault.com/a/301984/118544

However, for my purposes, because I am interested in routing only web traffic, it seems what I can do is to make requests to certain hosts go to localhost using /etc/hosts and then use a local Apache instance and mod_rewrite to forward requests on to different hosts when the host header matches.

You must log in to answer this question.

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