Point multiple IP addresses to a single host name

Solution 1:

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 192.168.244.128, the next would receive 192.168.226.129, 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).

Solution 2:

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).


Solution 3:

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

Scenario:

  • 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. gateway.net

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.


Solution 4:

From http://www.unc.edu/atn/lsf/docs/7.0.5/lsf_config_ref/index.htm?hosts.5.html~main

IPv4 Example

192.168.1.1 hostA hostB 192.168.2.2 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.