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

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

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.

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.
–
mydoghaswormsJun 5 '13 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.
–
StephaneJun 5 '13 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.
–
mydoghaswormsJun 5 '13 at 16:25

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.