hostname : name or service not known

Pour ceux qui galèrent avec leur hostname en FQDN, voici le tuto à suivre :

Getting the FQDN to work properly can be a b*tch. 😉

Basically, for the FQDN resolution to work correctly, three (or four)
things need to play together. That’s the files /etc/hostname,
/etc/hosts, /etc/resolv.conf and your external nameserver (provided by
your hoster e.g.).

Let’s say your server’s hostname is “lyra” and its already
established and externally resolvable domain name is “”. Let’s
further say that lyra’s IP is, and the nameserver that
forwards requests to the outside has the IP (real-life
example from my experimental Virtualmin VM).

Then the contents need to be as follows:



/etc/hosts       localhost lyra

(Note that I have both the FQDN and the standalone hostname there.)



After setting these contents, it might be helpful/required to reboot the machine or execute /etc/init.d/networking restart, though usually that’s not necessary.

hostname should then reply with “lyra”, and hostname -f with “”.

If you still have trouble then, you can additionally check the file /etc/nsswitch.conf which tells the system which facilities to consult for resolving various stuff. You should have a line like this there:

hosts: files dns

If it’s missing or deviating, edit it to this.

Leave a Reply

Your email address will not be published. Required fields are marked *