Determining the Order in Which a Name Server Returns Answers

3.19.1 Problem

You want a name server to return certain answers in a particular order.

3.19.2 Solution

Use the rrset-order options substatement in BIND 8 or BIND 9.3.0 and later.

In BIND 8, rrset-order lets you choose to give out answers that include multiple resource records in one of three orders:


The default, often referred to as round robin. The order in which records are returned is rotated between responses, with the first record given out in the previous answer moved to the end in the next answer.


Records are always returned in the same order.


Records are returned in a random order.

rrset-order also lets you select the particular answers an order applies to using three qualifiers:


The order only applies to answers to queries for the specified domain name, which may include a wildcard as its leftmost label. The default is "*".


The order only applies to answers to queries in the specified class, which defaults to IN.


The order only applies to queries for the specified type of record. The default is ANY, or any type of record.

The default behavior, then, is equivalent to:

 rrset-order {
 name "*" class IN type ANY order cyclic;

So, to return the A records of your web server in a fixed order, you might use:

options {
 rrset-order {
 name "" type A order fixed;

You'd want to make sure that's A records appeared in the correct order in the foo.example zone data file, of course.

Versions of BIND from 9.3.0 on support just the cyclic and random orders.

3.19.3 Discussion

BIND 9 doesn't support true round robin, in which the name server tracks the order in which it gives out the records in an answer. Instead, it randomly chooses a starting point in the list of records and then places the remaining records into the response as though the first record had rotated to the beginning. For example, say had the following three A records: IN A

A BIND 9 name server might choose the third A record as the starting point, and then would insert the next two A records ( and to produce a response in the following order: IN A

If what you want to do is sort addresses on certain networks to the front of responses, you need to configure the sortlist. See Recipe 3.28.

3.19.4 See Also

Section 2.8 for setting up round robin and "The rrset-order Substatement" in Chapter 10 of DNS and BIND for more information on rrset-order.

Getting Started

Zone Data

BIND Name Server Configuration

Electronic Mail

BIND Name Server Operations

Delegation and Registration


Interoperability and Upgrading

Resolvers and Programming

Logging and Troubleshooting


DNS & BIND Cookbook
DNS & BIND Cookbook
ISBN: 0596004109
EAN: 2147483647
Year: 2005
Pages: 220
Authors: Cricket Liu © 2008-2020.
If you may any questions please contact us: