I always get confused what should the second column of the host file. Should it be a fqdn or alias? or it does not matter?
eg.
IPAddress Hostname Alias
127.0.0.1 localhost deep.openna.com
208.164.186.1 deep.openna.com deep
208.164.186.2 mail.openna.com mail
208.164.186.3 web.openna.com web
the above example has fqdn in the 2nd column but in first row, the second column is the alias name. When I check my host ( I am not a linux admin but trying to be ), has mixed. for the local server, the 2nd column has alias, but for the other server, the 2nd column has fqdn. more confused.
If any one could help me to understand, that would be great.
Thanks
K
Format of /etc/hosts file entry
-
- Posts: 10642
- Joined: 2005/08/05 15:19:54
- Location: Northern Illinois, USA
Re: Format of /etc/hosts file entry
man 5 hosts
should solve the mystery.
should solve the mystery.
-
- Posts: 46
- Joined: 2015/02/27 14:30:54
Re: Format of /etc/hosts file entry
No, it does not.gerald_clark wrote:man 5 hosts
should solve the mystery.
I have done my homework before I asked you. I am seriously working on it and want to understand. As I said, when I checked man(5) hosts, it says
Internet address
official host name
aliases
what is official hostname? I think this should be myhost(.mydomain.com). This is because official hostname is the short name . the long name is the fqdn not the hostname.
So it does not work that way too as I have seen fqdn in the 2nd column.
Can I conclude that it does not matter?
Also, in another note, I have seen hostname as fqdn. Is not hostname different from dnqn or we can use them interchangeable ? or does not matter?
thanks
Kiran
-
- Posts: 10642
- Joined: 2005/08/05 15:19:54
- Location: Northern Illinois, USA
Re: Format of /etc/hosts file entry
On my CentOS 6 system, man hosts says each line should be present with the following information:
IP_address canonical_hostname [aliases...]
There are examples at the bottom of the page.
IP_address canonical_hostname [aliases...]
There are examples at the bottom of the page.
Re: Format of /etc/hosts file entry
Odd, my CentOS-6 doesn't have a man hosts.
Anyway, I do
192.168.1.5 scott1.scottro.net scott1
I've also found--never really kept track of this but on some machines, not having this will make things like startx hang which it does hosts -f, that for the 127.0.0.1 address, I have things like
127.0.0.1 scott1.scottro.net scott1 localhost.localdomain localhost.
That's the order I will have it in and it's never broken anything. Wonder why I don't have man hosts. <shrug>
Anyway, I do
192.168.1.5 scott1.scottro.net scott1
I've also found--never really kept track of this but on some machines, not having this will make things like startx hang which it does hosts -f, that for the 127.0.0.1 address, I have things like
127.0.0.1 scott1.scottro.net scott1 localhost.localdomain localhost.
That's the order I will have it in and it's never broken anything. Wonder why I don't have man hosts. <shrug>
New users should check the FAQ and Read Me First pages
-
- Posts: 10642
- Joined: 2005/08/05 15:19:54
- Location: Northern Illinois, USA
Re: Format of /etc/hosts file entry
It's supplied by man-pages-3.22-20.el6.noarch.rpm