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

Can anyone explain whether it is possible for two hostnames to share the same IP address?

And what about if one hostname represents more than one IP address, is that possible too? Why?

share|improve this question
Want a real world example where it happens? Ping and and look at the IP address that is returned for both. – Scott Chamberlain Jun 21 '13 at 16:32
All hostnames already share the address, sort of ... – jlliagre Jun 24 '13 at 23:01
up vote 39 down vote accepted

Assigning more than one IP address to one hostname is also possible:        A        A        A        A

When you query a DNS server for you'll get back a list of IP addresses back. You can then choose to connect to one of them. Should the first attempt to connect get actively refused, just try the next.

Most browser will follow this flow, as long as the endpoints actively refuse TCP connectivity. Should an endpoint timeout, the ressource will be treated as unreachable even though not all IP's has been tried

Since most applications (browsers included) are often only interested in 1 IP endpoint at a time and just choose the first available answer, you risk skewing the load between the target servers so that the first server gets all the traffic while the others might be idle.

To circumvent this, most DNS servers offer what is known as a Round Robin configuration, making the server alternate the order in which equally matching records are returned. Before load balancers were commonplace, this was an efficient way to load balance and somewhat implement fault-tolerance on network systems.

share|improve this answer
Isn't the question asking the reverse of this? – mowwwalker Jun 21 '13 at 17:33
There are two questions. @Sirch already covered the first part pretty good – Mathias R. Jessen Jun 21 '13 at 17:38
Oh, I see, I skipped over the description. Thank you for the answer btw! – mowwwalker Jun 21 '13 at 17:49
Do browsers/network stacks typically try the first address received? Or will they try a random one? Would it make sense to randomize the order IPs are returned by your DNS server to try to balance the load? – Tom Marthenal Jun 21 '13 at 19:12
Depends on the specific client implementation. Most servers will randomize the order of returned IP addresses (this is the behavior referred to as "round-robin"). Interesting questions actually, I think I'll expand on the answer a bit – Mathias R. Jessen Jun 21 '13 at 19:20

Yes, it is possible for multiple hostnames to use the same ip address, the best practise is to use a CNAME record to point to the A record        CNAME        A

Take note of all the full stops.

Having one hostname to represent multiple ip addresses is a little more complicated. If we are talking about MX records, this solution already exists in DNS using priority numbers, if you want it to represent multiple A records, youd better to use a load balancer, HAProxy for example.

share|improve this answer
It is worth noting, and I've seen on the real Internet, chains of CNAMEs that broke name resolvers. Because a CNAME can point to another CNAME. Even CNAME loops are possible. – PP. Jun 21 '13 at 11:24
RFC 1912 2.4 – dmourati Jun 21 '13 at 17:08
It's also worth pointing out that A records containing the same IP can appear in different zones, e.g., A and A – Blrfl Jun 23 '13 at 12:58
This answer forgets to tell about wildcard A records, which also lead to multiple hostnames on the same IP. – mkzero Jun 24 '13 at 22:44
Hey Sirch, What's the deal with the fullstops? – JonoRR Oct 20 '14 at 10:12

In addition to CNAME change as other answers suggested, you also have to handle the logic on your hosting server. I use Apache and I configured it as:



I'm sure other http server softwares have similar things.

share|improve this answer

You need to be clear on what you mean by two hostnames. If you mean two physical boxes with the same IP address the answer is typically no. A case where you would is if serverA and serverB are working as an active-passive cluster then you would have each server have two addresses a piece. One would be an ip address dedicated to that server and the second ip address would be one which was shared between the servers but only the active server will be listening to that shared address. The passive server only starts listening in the shared address when the active server goes down.

share|improve this answer

It is also worth noting that in IPv6 you can assign the same IP to two or more hosts and the network will do the load balancing and failover for you (if one is not reachable, try the other). Both are regarded as one logical endpoint and there is no DNS involved whatsoever.

This feature is known as Anycast.

share|improve this answer

Multiple IP for a same Domain:

  • Yes, it is possible and very common: If a server (with ip A) fall down, you may connect to the next IP of the DNS register and access an another server (with ip B) to get the service.

Multiple Domain for a same IP:

You need to answer the next question: Are all Domain providing the same service?

  • If yes: it is a very common configuration also: lot of companies buy lot of domain with different country top domain:,,, etc. And all of them point to the same service, that is, to the same list of IP.
  • If no: It is possible but not common and not recomended. Some hosting companies that only allow HTTP service use NAT/Proxy to spare IP. But of course, that mean a Proxy that "understand" HTTP to identivy the destination service.
share|improve this answer

Many servers in telecom(like HSS and PCRF) use SCTP transport and so these servers have multiple IP addresses. These addresses are used for multi-homing(which SCTP supports) providing the connection with redundancy and failover.

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.