Mes trouvailles du jour : 23 August 2012

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 “tianet.de”. Let’s
further say that lyra’s IP is 46.4.181.243, and the nameserver that
forwards requests to the outside has the IP 46.4.181.241 (real-life
example from my experimental Virtualmin VM).

Then the contents need to be as follows:

/etc/hostname

lyra

/etc/hosts

127.0.0.1       localhost
46.4.181.243    lyra.tianet.de lyra

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

/etc/resolv.conf

nameserver 46.4.181.241
domain tianet.de

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 “lyra.tianet.de”.

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.

Mes trouvailles du jour : 20 August 2012

Mes trouvailles du jour : 17 August 2012