Using Sortlist

Sortlist is a complicated feature which allows for the ordering of A and AAAA records in answers to be modified, optionally dependently on who is asking. Since clients frequently connect to the ‘first’ IP address they see, this can effectively allow you to make sure that user from, say also preferably connect to servers in

The syntax consists of a netmask for which this ordering instruction applies, followed by a set of netmask (groups) which describe the desired ordering. So an ordering instruction of “”, “” will put anything within 1/8 first, and anything in 2/8 second. Other IP addresses would follow behind the addresses sorted earlier.

If netmasks are grouped, this means these get equal ordering.


New in version 5.1.0: Alternative equivalent YAML setting: recursor.sortlists.

addSortList() is used in the lua-config-file and is intended to exactly mirror the semantics of the BIND sortlist option, but the syntax is slightly different.

As an example, the following BIND sortlist:

{; {;;
{;;};;; }; };

Gets transformed into:

addSortList("", {"", "",
{"", ""}, "",
"" })

In other words: each IP address is put within quotes, and are separated by commas instead of semicolons. For the rest everything is identical.