Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do I automate my usage of three VM machines which require me to add a IP aliased to a name in my HOSTS file. I upload code to the server of choice and then I go to the address http:/ / serverVM/blah and view the program. The basic idea is that I want to be able to add multiple IP addresses in my HOSTS file all with the same alias "serverVM", so that no matter which server I use, I don't have to modify my HOSTS and reboot.

So example: serverVM serverVM serverVM

You might ask why I don't just do: http:/ / Well it's because the application I use requires the alias "serverVM" because of a cookie and the application won't work correcly otherwise.

The problem is I don't think this is possible with the HOSTS file. Each server is different and I want to chose which one to use at any given time, I can't just use any of them.

Is there a way to solve my dilemma?

share|improve this question
Which OS are you using for your host? Is your application just expecting the Host: serverVM header to be present in a web request? If so you could use an HTTP proxy like Fiddler to add or modify the header. – heavyd Feb 14 '13 at 15:47
The serverVM is running CentOS, my local machine is Windows 7. I have to type in my browser Http:// serverVM/blah to get it working correctly. – DemiSheep Feb 14 '13 at 15:56
Another problem you are going to find is that if you use SSH, it will complain about the host key having changed. On some users' settings, this might prevent access to the server. – mdpc Feb 14 '13 at 19:23
Unless I'm not understanding your setup, why can't you clear the cookie in the application and fix your aliases? – Kruug Feb 14 '13 at 19:57
What do you mean fix my aliases? I've been changing my alias IP in my HOSTS file and rebooting, I don't want to reboot. – DemiSheep Feb 15 '13 at 12:19

Download Fiddler and the Syntax-Highlighting Addon. Open the program once thet have been installed. Fiddler is an HTTP proxy which allows you to modify HTTP requests before they are sent to the server.

In Fiddler select the "Fiddler Script" tab. Find the OnBeforeRequest function and add the following code inside that method:

    var prev = oSession.hostname,
        newIp = prev;

    oSession.hostname = "serverVM";

    if(prev == "serverVM1") {
        newIp = "";
    } else if(prev == "serverVM2") {
        newIp = "";
    } else if(prev == "serverVM3") {
        newIp = "";

    oSession["x-overrideHost"] = newIp;

Now you should be able to access your three differnt servers using http://serverVM1, http://serverVM2 and http://serverVM3.

share|improve this answer
I am not seeing a "Fiddler Script" tab... I installed Fiddler Web Debugger v2.4.2.6 – DemiSheep Feb 14 '13 at 18:13
Sorry, forgot I had an addon installed. See the update please. – heavyd Feb 14 '13 at 18:53
I am not getting this to work. I have removed the line(s) from my HOSTS file. I have set "Use Fiddler automatically" and turned on Fiddler, I also tried setting Fiddler to force traffic through it. Does it matter if the address is http or https? Because the link is https. – DemiSheep Feb 20 '13 at 13:42
http would be simpler, but Fiddler can handle https, it just requires a bit more configuration. I would try over http first if possible. – heavyd Feb 20 '13 at 15:13
up vote 0 down vote accepted

I gave up on this mostly, as I don't need to access so many machines after all and I found out I can simply close my browser and reopen it when I modify my hosts file.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.