Hostname fails to give FQDN

November 2010


The file/etc/hosts on an Ubuntu Lucid machine starts with:

127.0.0.1 localhost.localdomain localhost
127.0.1.1 somehost
10.0.237.13  somehost.mydomain somehost
<snip>
    

and hostname -f gives:

jurjen@somehost:~$ sudo hostname
somehost
jurjen@somehost:~$ sudo hostname -f
somehost

According to Debian Bug 316099, the 127.0.1.1 entry should exist. But its presence before the public range IP number hampers FQDN resolution. We remedy the situation by swapping the last two lines:

127.0.0.1 localhost.localdomain localhost
10.0.237.13  somehost.mydomain somehost
127.0.1.1 somehost
<snip>
    

gives:

jurjen@comehost:~$ hostname
    somehost
    jurjen@somehost:~$ hostname -f
    somehost.mydomain