resolv.conf limited to six domains with a total of 256 characters

This question has been asked off and on since the 1990s. It's still the same answer.

As Jakub Jelinek of RedHat said 10 years ago, this limit is hardwired into the BIND DNS client library that is contained within GNU libc. It's not configurable at run-time, and it's unlikely to be altered by operating system distributors as that breaks binary compatibility with some third-party programs that use this part of GNU libc.

Of course, if one is capable one can always change the parameter, and recompile from source both GNU libc and all of the programs that use it. However, this is a lot of work just to make

ssh pescado
look in more than 6 places in the DNS namespace tree to find a machine named pescado. ☺

Further reading

  • Jakub Jelinek (2005-09-14). DNS resolver's 'MAXDNSRCH 6' value is too small. 168253. RedHat bugzilla.
  • Jakub Jelinek (2006-12-15) . RFE: More search domains in /etc/resolv.conf. 219778. RedHat bugzilla.
  • Jean-Marc Pouchoulon (2002-04-25). resolv.conf manage more than 6 domains. bind-users.

From the man page for resolv.conf

In glibc 2.25 and earlier, the search list is limited to six domains with a total of 256 characters. Since glibc 2.26, the search list is unlimited.

As such, upgrading glibc should resolve this issue. For Debians Buster and after, along with Ubuntus 17.10 and after, the package version of glibc is at or above 2.26, and only requires an apt update. It is possible to upgrade by hand if necessary otherwise.

RHEL8 is baselined on glibc version 2.28 so no update is required; (and unreasonable for RHEL7 and earlier). Per distrowatch, Fedora 27 was the first to implement glibc 2.26.


You can't increase the number of search domains.

However, you can:

  1. add entries to /etc/hosts with the IP address, full hostname, and a short alias. NOTE: that if the host's IP address changes you will have to update the /etc/hosts entry, so this a) defeats the purpose of DNS, and b) is likely to be an annoying "solution" in the medium-to-long term.

  2. if by "jump to other machines", you meanssh to them, you can add definitions for hosts in your ~/.ssh/config file. You can then ssh to those hosts using either the fully-qualified-domain name OR the short name you give it in the config.

e.g.

Host foo
   Hostname foo.example.com
   User cas

ssh foo would attempt to ssh to foo.example.com with remote username cas.

Tags:

Dns

Resolvconf