Hostname not respecting search domain

Brandon Vincent Brandon.Vincent at asu.edu
Thu Aug 6 22:32:01 UTC 2015


On Thu, Aug 6, 2015 at 2:06 PM, Andrew Langhorn <andrew at ajlanghorn.com> wrote:
> There is a search domain set in `/etc/network/interfaces` and I've given one
> to `/etc/resolv.conf` using resolvconf, specifying the correct network
> interface.

The hostname(1) utility utilizes the name resolution functions of
glibc to return various information about the system. The search list
and domain options in /etc/resolv.conf relate to how the glibc
resolver constructs DNS queries.

When you run hostname -f, the system first takes the system hostname
(e.g. test01) and attempts to get a hostent structure (name and IP
address) in return. It first tries to do this by looking for an entry
in /etc/hosts. If no entry exists, the glibc resolver will make DNS
queries for test01 with various combinations of the default domain and
search list appended until it recieves a result. There are other ways
glibc can return a hostname (e.g. myhostname), but this is usually the
default.

hostname -f, then takes this hostent structure and uses the portion
after the first dot as the returned domain name.

If you want the system to return an entry for hostname -f, your
options are to change your hostname to the FQDN, add an entry to
/etc/hosts, or to get a proper DNS infrastructure in place.

Brandon Vincent




More information about the ubuntu-users mailing list