Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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

In Windows System, there is this file at C:\WINDOWS\system32\drivers\etc\hosts. This file allows us to default a specific IP address to a host name.

The issue now is whether I can set multiple IP addresses to a host name. For example, can I do something like this:

And expect that the browser can resolve to both of them, see which one will work and thus point at that one?

If not, is there any other way to get the behavior I want?

Note: I am deploying this app in my own local area network, so there is no need for internet.

share|improve this question
up vote 16 down vote accepted

Normally you would not uses hosts to do this, but your DNS. Most DNS will provide what's called a "Round Robin" if you assign multiple A records to the one name in the zone.

What it would do then, is the first request comes through would receive, the next would receive, so on and so forth. However, by design, your local machine will cache its DNS resolution, and will usually use the same IP address over and over, until it expires (Time To Live, TTL).

share|improve this answer
EDIT: Nevermind, I stand corrected!! Posted Below – MagnaVis Feb 13 '15 at 4:24

I think you are going about this the wrong way. Let me know if I'm making the wrong assumptions here.


  • You have two windows servers running the same web application, probably on IIS.
  • You want your application to be fault tolerant so that if one of the servers fails, your application is still available.
  • You want this fault tolerance to be transparent to the browser, so that users can continue to access the application with the same hostname i.e.

What your trying to do is called round-robin DNS (aka poor mans load balancing) , but your trying to do this from the client side. This does not seem to have the desired effect (at least on my Windows XP box) even if i flush the DNS cache. Windows will only resolve to the first IP in the file. Nonetheless round-robin DNS is not fault tolerant, so this won't help you achieve what you want.

Suggested solution:

Hardware load balancer: Some brand names are Alteon, Big-IP, Barracuda. What this does is basically present a single IP for your users to connect to & it forwards the requests to the web servers. If one of the servers becomes unavailable, then it will no longer forward traffic to it. This is the expensive option.

Network Load Balancing Services: This is a Microsoft technology available on windows server, which will give you a single clustered IP. It achieves the same result as a hardware load balancer, but in a different way. All you need to do is configure it.

share|improve this answer
ZEN-LB is a really simple and easy load balancer. We've had a lot of success with it and love it because its open source (free.) – Derrick Jan 31 '13 at 17:49

Yes, you can do this, I've used it to test round-robin DNS scenarios without having to actually enter the hosts in a DNS.

When an application calls gethostbyname, it gets back the full list of IP addresses (possibly in random order - depending on the libraries / OS).

share|improve this answer
+1 for actually answering the question – CLF Sep 4 '15 at 13:02
u mean to say it will pick one randomly..i have a windows server – Lakshay Jul 7 at 11:24


IPv4 Example hostA hostB hostA hostC host-C

In this example, hostA has 2 IP addresses and 3 aliases. The alias hostB specifies the first address, and the aliases hostC and host-C specify the second address. LSF uses the official host name, hostA, to identify that both IP addresses belong to the same host.

share|improve this answer
"The format of LSF_CONFDIR/hosts is similar to the format of the /etc/hosts file on UNIX machines." I.e.: the source is not about regular hosts files. – gertvdijk Jan 27 '13 at 0:57

My suggestion is to use an internal DNS server with DNS round-robin and TTL=0. If you update the DNS record (also with automatic ip checking system) when an IP/server is down, you can have an high-availability system.

share|improve this answer
This is not a solution for high availability. DNS is not designed for this and should only be used in conjunction with other fail over methods. A lot of resolvers ignore the TTL cache as well, making this method unreliable. – Mark Henderson Oct 5 '09 at 20:41

I have done this on a home network where I assign static IPs to both the wired and wireless network interfaces of a laptop, and from another machine's hosts file point a single hostname to both those ip addresses. It seems to work fine.

share|improve this answer

@ Plamen Dimitrov You'll need a device to handle that kind of balance, possibly a switch that can handle BGP in front of your FW- or use your FW if it's capable. If your Ciscos handle BGP look into implementing that. This way you can have both of your ISPs IP going into the Cisco/or switch and the target servers would have valid IPs of 24-bit public IPs (DIFFERENT FROM THE 2 ISP IPs). At that point (you're using 3 different public IP blocks, the one for your servers MUST BE 24 BIT), you'd need to have each of your ISPs know about this solution and they'd have to be willing to support the BGP solution between them, which most will do. Now, when your FQDN resolves, it will resolve to your 24 bit block of IPs, even if 1 ISP lines goes down. The goal is, your 24-bit addresses will always be available due to your ISPs agreeing to route that 24bit address through their lines. This works for VPN too since all you're using for VPN are the 24bit addresses, not either of the IPs from the ISP that you plugged into your cisco/or switch. At that point you have to be wary of BGP FLAPPING where if your lines go up and down a lot, due to a line getting DOS, the DNS addresses will change so much, on the internet, that the DNS servers will AUTOMATICALLY REMOVE THE IPs THAT LEAD TO YOUR 24 BIT BLOCK OF IPs. That's a DOS attack on BGP solutions.

share|improve this answer


IPv4 Example hostA hostB hostA hostC host-C

In this example, hostA has 2 IP addresses and 3 aliases. The alias hostB specifies the first address, and the aliases hostC and host-C specify the second address. LSF uses the official host name, hostA, to identify that both IP addresses belong to the same host.

Based on this example I did the following 10.18.y.x 192.168.z.x hostA

Where hostA is the hostname of a server I intend to reach from both internal network (192.168.y.x) and VPN (10.8.z.x).

ping hostA
sending 'ping' on 192.168.y.x [10.8.z.x]
Answer from 10.8.z.x : bytes=32 time=98 ms TTL=64
Answer from 10.8.z.x : bytes=32 time=78 ms TTL=64
Answer from 10.8.z.x : bytes=32 time=111 ms TTL=64
Answer from 10.8.z.x : bytes=32 time=136 ms TTL=64

So it works well and I'm able to get samba working through VNP using hostname so it's fine for me to have my connected drives in windows in both case (LAN or VPN connected).

Best regards.

share|improve this answer

You can't do this with the hosts file.

You can't do this with DNS either: you can serve multiple IPs for a single name, but the browser will pick just one of those multiple IPs, try it, and if this host is currently down, the browser will display a connection error.

One possible solution is to set up a proxy server and configure these two IPs as the parents for the domain they serve. At least in the case of Squid, the proxy will try one server and, if it fails, try the second server. Then configure your browser to use this proxy server.

share|improve this answer
Not true about round robin: Note that the likes of google return multiple DNS records. Despite RFC3484 reordering, it obviously helps to return multiple IPs as a failover strategy. – BrianEss Oct 7 '09 at 21:56
yes you can do it with the hosts file – warren Nov 28 '09 at 7:11

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.