mercredi 25 février 2015

Understand hostname and /etc/hosts


In /etc/hostname, I have myname.


In /etc/hosts, I have :



127.0.0.1 localhost.localdomain localhost myname
::1 localhost.localdomain localhost myname


I have a vague understanding of what really is a hostname and what it is used for.


These more precise questions could help me to understand it better:




  1. What really is my hostname in the example above? myname or something else? If I had instead myname.domain.com in /etc/hostname, what would be my real hostname then?




  2. In the example, the command hostname returns myname, whereas the command hostname -f returns localhost.localdomain. I had in mind that /etc/hosts was only a mapping between names and ip addresses. It seems to serve another function here. What is a fqdn and what is it used for? How is it retrieved? Why is it localhost.localdomain?




  3. If I had instead myname.domain.com in /etc/hostname, hostname -f would return myname.domain.com. Why?




  4. Why aren't fqdn ending with a dot in these files?




  5. Are hostname -d and dnsmydomain equivalent?




  6. In what context can I use my hostname (myname) and when do I have to use my fqdn (localhost.localdomain)?





Aucun commentaire:

Enregistrer un commentaire