Take the 2-minute tour ×

Now I have alreaady set the NS records for both webhosts to the sub domain but I do not know if there exists a priority.
How do accompolish this task if it is possible?

share|improve this question
add comment

migrated from stackoverflow.com Oct 9 '12 at 10:16

This question came from our site for professional and enthusiast programmers.

2 Answers

up vote 0 down vote accepted

You can't achieve that with DNS alone, since there is no priority field in A or CNAME records. What you wish to do can be accomplished with the following:

  1. In cPanel, create two A records pointing to webhostA and webhostB
  2. Your visitors' browsers will pick a random host (actually the DNS server usually does round-robin i.e. returns the records in random order, and the browser takes the first one). In other words, you have no control over which client goes where, it will be distributed roughly equally among the webhosts.
  3. If either webhostA or webhostB is down, your visitors' browsers should try the other one.

There are more complicated setups like geo-targeted global DNS-based load balancing, or using local load balancers, but those do not sound like they fit your use case.

share|improve this answer
Can this be done using two NS records? –  Abhishek Bhatia Oct 10 '12 at 8:10
You could do it in the DNS with SRV records. They have all what you need (priority and weight). It works with several protocols (such as XMPP) but not with HTTP, unfortunately. –  bortzmeyer Oct 10 '12 at 20:19
need it for http :( –  Abhishek Bhatia Oct 10 '12 at 21:46
I'm not sure how NS records could give you the advantages you're looking for. –  Wil Tan Oct 12 '12 at 13:23
add comment

It sounds like you are conflating DNS hosting with web hosting. You need to treat them separately.

DNS hosting

Your domain should be hosted on a set of consistent nameservers. By consistent I mean that all nameservers for your domain should be serving the same data, deriving from the same zone file. The standard way to do this is to use one namemaster server and one or more nameservers that are configured to be slaves of that master.

Your DNS can be hosted by the same providers that host the web site or somewhere else. As long as there is one master nameserver and all the others are slaves from it. Because your domain is not directly under a gTLD or ccTLD, you also have the option of not delegating it at all and just putting A and AAAA records in the parent domain's zone file (you say you can do this with Cpanel).

Web hosting

I don't think you can achieve your failover goal using DNS. You can put multiple A and AAAA records in DNS pointing to different instances of the web site, but clients will use them all more or less randomly and uniformally.

You could use a load balancer that sits on front of the web site but then the load balancer becomes a single point of failure.

You could set the TTL of the A and AAAA records to a low value (like 5 minutes) and change them when the primary instance of the web site fails, either manually or automatically (e.g. via dynamic DNS).

You could use an anycast IP address with the secondary instance announcing the route to the block containing the anycast address with lower priority, but that requires a portable IP address block and BGP.

share|improve this answer
add comment

Your Answer


