SDB:Host name, domain name
Comparison to other systems
When you invoke the commands hostname
and domainname
, on different UNIX[tm] based sy
stems you get --- different answers depending on the and the system (e.g.: AIX, HP-UX, OSF/1, IRIX) --- back.
hostname
traditionally returns either the system's short name or sometimes the full DNS domain na
me. This depends totally on how the system is configured by your SysAdmin. DNS is the abbreviation for domain
name server.
The command domainname
often delivers either nothing or the usual domainname. More exceptionally, but still possible; The delivered domainname is different from the domain used in the hostname.
International settings
The explanation for this different behaviour is located in literature.
- Two books about this topic
- Linux Network Administrator's Guide by Olaf Kirch
(O'Reilly serie, ISBN 1-56592-087-2) - TCP/IP Netzwerk Administration by Craig Hunt
(O'Reilly serie, ISBN 3-930673-02-9)
In this article we describe that there should be no difference whether you use the short hostname Nickname or the fully qualified domain name.
The command hostname
looks in /etc/resolve.conf
or directly in /etc/hosts
for the giveen name thus providing the fully qualified hostname. Under Linux the command hostname -f<
/code> always returns the fully qualified hostname and the command <code>hostname -s
always the short hostname. An entry in /etc/hosts
always resembles the pattern:
IP_Address Full_qualified_Hostname Nickname
More nicknames can be declared, but only the first name after the IP address is the system's fully qualified name and this one must correspond to an eventual available name server! In few words: The system's fully qualified name is either defined by /etc/hosts
or by a name server.
More confusing is the command domainname
. By invoking it, the domainname used in the fully qualified hostname (the so-called DNS domain, DNS comes from domain name server) can appear --- however this must not be so!
- Reason
domainname
returns exclusively the NIS system's used domain, that is, the yellow pages s ystem's domain for the password distribution in a NIS domain. Such a NIS domain can be identical to the domain used in the fully qualified hostname --- in many NIS systems another name is used for the NIS domain.
To make things even more complicated :-), there still is the command ypdomainname
. It always returns the same output as domainname
: the NIS domain's name. With it, the NIS domain can be set either with the command domainname
or ypdomainname
. Without it the system must be integrated in a NIS domain.
If you would like to know your DNS domain's name, as well as the fully qualified hostname's domain, either execute the command:
hostname -d
or
dnsdomainname
.
Hint
If you prefer a shorter name for your SuSE Linux system, change the line in /sbin/init.d/boot
<now
iki>: </nowiki>
test -n "$FQHOSTNAME" && hostname $FQHOSTNAME
to:
test -n "$FQHOSTNAME" && hostname ${FQHOSTNAME%%.*}
After this change and a reboot, the command hostname
returns the system's short hostname and hostname -f
the full qualified hostname.
<keyword>hostname,domainname,nickname,name,host</keyword>