Home > Uncategorized > SuSE/SLES: hostname does neither print domain name nor fully qualified hostname

SuSE/SLES: hostname does neither print domain name nor fully qualified hostname

Problem description:

The hostname command does not recognise the domainname and will not use it in its output formats:

sles01:~ # hostname
sles01
sles01:~ # hostname -f
sles01
sles01:~ # hostname -d
 
sles01:~ #

Although the configuration seems correct:

  • /etc/HOSTNAME:

    sles01:~ # cat /etc/HOSTNAME
    sles01.mydomain
    sles01:~ #
  • /etc/resolv.conf:

    sles01:~ # cat /etc/resolv.conf
    search mydomain
    nameserver 192.168.0.1
    sles01:~ #

Problem resolution:

Check your /etc/hosts file and the order of the entries for your host. The fully qualified domain name should be in first position. In my case, the hosts-file somehow contained an entry with a wrong order:

sles01:~ # cat /etc/hosts
#
# hosts         This file describes a number of hostname-to-address
#               mappings for the TCP/IP subsystem.  It is mostly
#               used at boot time, when no name servers are running.
#               On small systems, this file can be used instead of a
#               "named" name server.
# Syntax:
#
# IP-Address  Full-Qualified-Hostname  Short-Hostname
#
 
127.0.0.1       localhost
 
192.168.0.100   sles01 sles01.mydomain
sles01:~ #

Example for a correct order of the entries:

sles01:~ # cat /etc/hosts
#
# hosts         This file describes a number of hostname-to-address
#               mappings for the TCP/IP subsystem.  It is mostly
#               used at boot time, when no name servers are running.
#               On small systems, this file can be used instead of a
#               "named" name server.
# Syntax:
#
# IP-Address  Full-Qualified-Hostname  Short-Hostname
#
 
127.0.0.1       localhost
 
192.168.0.100   sles01.mydomain sles01
sles01:~ #
Categories: Uncategorized Tags:
  1. No comments yet.
  1. No trackbacks yet.

Connect with Facebook