The file /etc/HOSTNAME
on SuSE-Linux contains the host name.
Should this be the full qualified domain name, or the short name (without ".")?
Related question: socket.getfqdn() returns no domain, but socket.gethostname() does?
Answer
Please note that AFAIK the upper-case /etc/HOSTNAME
is specific to SuSe systems, but that should be a symbolic link to the a lowercase file name /etc/hostname
, which is used by systemd and should be therefore be present on other distributions as well.
The recommend systemd utility hostnamectl
distinguishes three different hostnames:
- the high-level "pretty" hostname which might include all
kinds of special characters (e.g. "Lennart's Laptop"), which is stored in/etc/machine-info
the static hostname which is used to initialize the
kernel hostname at boot (e.g. "lennarts-laptop"), which is stored in/etc/hostname
the transient hostname which is a default received from
network configuration.
The manual page for the hostname configuration file man 5 hostname
doesn't really explicitly use the term FQDN but states:
The
/etc/hostname
file configures the name of the local system that is set during boot using the
sethostname(2)
system call. It should contain a single newline-terminated hostname string.
Comments (lines
starting with a `#') are ignored.
The hostname may be a free-form string up to 64 characters in length;
however, it is recommended that it consists only of 7-bit ASCII lower-case characters and no spaces or dots,
and limits itself to the format allowed for DNS domain name labels, even though this is not a strict
requirement.
Where the "no dots" is the only hint that the hostname file should only contain the system host name component, without a domain suffix and therefore not a FQDN.
The manual for the hostname
command is more explicit (man 1 hostname
) :
You can't change the FQDN (as returned by
hostname --fqdn
) or the DNS domain name with this [sic: thehostname
] command. The FQDN of the system is the name that the resolver(3) returns for the host name.
In other words, the hostname is NOT the FQDN.
And then on how to configure the FQDN:
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.
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.
BTW: If you do use a FQDN such as myhost.example.com
as hostname and in /etc/hostname
, things like dnsdomain
and hostname -d
will return empty strings and will NOT split that string at the first dot into a DNS hostname component myhost
and a domain name component example.com
No comments:
Post a Comment