Scenario / Questions
On Ubuntu 10.04, should /etc/hostname contain the server’s fully-qualified domain name?
Find below all possible solutions or suggestions for the above questions..
No, just the hostname portion. According to Ubuntu’s man pages,
/etc/hostname should contain only the hostname portion of the hostname, not the FQDN:
You can’t change the FQDN
(as returned by hostname –fqdn) or
the DNS domain name (as returned by
dnsdomainname) with this command. The
FQDN of the system is the name that
the resolver(3) returns for the host
Technically: The FQDN is the name
gethostbyname(2) returns for the host
name returned by gethostname(2). The
DNS domain name is the part after the
Therefore it depends on the
configuration (usually in
/etc/host.conf) how you can change
it. Usually (if the hosts file is
parsed before DNS or NIS) you can
change it in /etc/hosts.
The address families hostname tries when looking up the FQDN,
and network addresses of the host are determined by the
of your resolver. For instance, on GNU Libc systems, the
be instructed to try IPv6 lookups first by using the inet6
option in /etc/resolv.conf.
/etc/hosts /etc/hostname This file should only contain domain name
and not the full FQDN.
Josh points out what Ubuntu recommends, but I’m not sure it’s a hard and fast rule.
/etc/hostname is used to set the system’s host name, which is the same thing as printed by
uname -n. That name will be used at login prompts, e.g. on the virtual console or at the Gnome GDM login screen.
As the man page says, it’s also used as the input to a DNS query when doing
hostname --fqdn or
Technically: The FQDN is the name gethostbyname(2) returns for the host name returned by gethostname(2). The DNS domain name is the part after the first dot.
Which means that if it’s a bare word, the resolver will append the domains listed in the
domain setting in
/etc/resolv.conf to try to find the FQDN. If you have an FQDN in /etc/hostname, it means it doesn’t have to try appending one or more domains: the name is unambiguous.
So I would say either is valid. I’d be very interested if anyone can demonstrate otherwise.
With libnss-myhostname installed, you can write the fqdn to
/etc/hostname and be done. Otherwise, you need to also edit
/etc/hosts to match the short name and map it to the fully qualified name (you can also put it in the dns, but that isn’t failsafe). Using a non-default loopback interface, this looks like:
127.0.0.2 hostname.fully.qualified hostname
Kubernetes Free Online Tutorial, Kubernetes Beginner Tutorial
DevOps Free Online Tutorial, DevOps Beginner Tutorial
Ansible Free Online Tutorial, Ansible Beginner Tutorial
Docker Free Online Tutorial, Docker Beginner Tutorial
Openstack Free Online Tutorial, Openstack Beginner Tutorial
Disclaimer: This has been sourced from a third party syndicated feed through internet. We are not responsibility or liability for its dependability, trustworthiness, reliability and data of the text. We reserves the sole right to alter, delete or remove (without notice) the content in its absolute discretion for any reason whatsoever.