Sign up ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I have a DNS record with three A records: the main site, and two backups. However, when clients perform a DNS lookup, they reach a backup site.

How can I change the order of the DNS records in's DNS server?

share|improve this question
As long as the DNS is working does it matter what order the DNS lookup resolves with? it's something you shouldn't need to do on regular basis anyhow. You could always write a PHP to do your own lookup and sort in the order you like. I'd be more concerned with hosting an important site on a free .tk domain :P – Simon Hayter Jul 29 '14 at 21:34

2 Answers 2

up vote 1 down vote accepted

You're touching on a "feature" of DNS known as DNS Round Robin. It's deliberate. You have no control over the order in which records which satisfy a particular query are provided.

It's crude; but surprisingly effective as a load-balancer.

If, in fact, the "backup" machines should not be touched unless the primary fails, you need to be more sophisticated with your zone files. You could change the TTL (time-to-live period) for the A record to a small number (e.g. 60 seconds) and then set up a script to change that A record via RFC 2136 when you want folks to fail over.

If you have 3 A records coughing up 3 different answers, you are supposed to get rough distribution equally amongst the 3. (one can also assume that M$ DNS will screw this up, but I don't actually know...)

share|improve this answer

The resource records that exist for a specific combination of name, class and type form what is called a resource record set (RRSet). Just like this term suggests (it being a set) there is no defined order for these records.

Even if you did have the authoritative nameservers for your zone, the only point where you have any actual control, answering with the records in some fixed order of your choosing it's still entirely possible (and actually common) for a resolver server to reorder them before passing the answer on to the client and even if the answer arrives in the desired order to the client host the resolver library can also reorder the result.

Just as an example, look at these queries issued in direct sequence to a caching resolver server:

$ dig @ +noall +answer

; <<>> DiG 9.9.4-P2-RedHat-9.9.4-15.P2.fc20 <<>> @ +noall +answer
; (1 server found)
;; global options: +cmd         275     IN      A         275     IN      A         275     IN      A         275     IN      A         275     IN      A         275     IN      A
$ dig @ +noall +answer

; <<>> DiG 9.9.4-P2-RedHat-9.9.4-15.P2.fc20 <<>> @ +noall +answer
; (1 server found)
;; global options: +cmd         274     IN      A         274     IN      A         274     IN      A         274     IN      A         274     IN      A         274     IN      A

From what it sounds like you are trying to achieve, I don't think adding multiple A records is part of the solution. It will at best give you a crude form of load balancing but never any kind of reliable 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.