[CentOS] /etc/hosts - hostname alias for

Robert Spangler mlists at zoominternet.net
Tue Mar 8 01:54:37 UTC 2011

On Monday 07 March 2011 15:22, the following was written:

>  Keith Keller wrote:
>  > On Mon, Mar 07, 2011 at 10:34:24AM -0600, Sean Carolan wrote:
>  >> Can anyone point out reasons why it might be a bad idea to put this
>  >> sort of line in your /etc/hosts file, eg, pointing the FQDN at the
>  >> loopback address?
>  >>
>  >>    hostname.domain.com hostname   localhost
>  >> localhost.localdomain

You can do this if you want.  The host file is only used by the machine it is 
on.  As to bad Idea it would depend on what you are trying to do and if the 
process you are trying to reach locally is listening on that ip address.

I have only the short name configured on

>  > Would the application work with a hosts entry like this?

If the process what configured to listen on that interface, yes.

>  >    hostname.dummy   localhost localhost.localdomain
>  >
>  > (Make sure you pick .dummy so as not to interfere with any other DNS.)

Why do you need the '.dummy'? short name should work fine.

>  > In theory you could leave off .dummy, but then you risk hostname being
>  > completed with the search domain in resolv.conf, which creates the
>  > problems already mentioned with putting hostname.domain.com in
>  > /etc/hosts.  (I have not tested this at all!)

Resolv.conf is not used for the hosts file, it is used for DNS.  I have my 
short name configured to the lo interface and the FQDN to the real ip 
address.  If I ping the short name I get this:

etc $ ping -c 3 bms
PING bms ( 56(84) bytes of data.
64 bytes from bms ( icmp_seq=1 ttl=64 time=0.038 ms
64 bytes from bms ( icmp_seq=2 ttl=64 time=0.038 ms
64 bytes from bms ( icmp_seq=3 ttl=64 time=0.037 ms

If I ping the FQDN I get this:

etc $ ping -c 3 bms.domain.com
PING bms.domain.com (x.x.x.x) 56(84) bytes of data.
64 bytes from bms.domain.com (x.x.x.x): icmp_seq=1 ttl=64 time=0.037 ms
64 bytes from bms.domain.com (x.x.x.x): icmp_seq=2 ttl=64 time=0.038 ms
64 bytes from bms.domain.com (x.x.x.x): icmp_seq=3 ttl=64 time=0.093 ms

>  And giving it would tell it others to ignore it, I think. Where
>  did your user come up with this idea - clearly, they have *no* clue what
>  they're doing, and need at least a brown bag lunch about TCP/IP, and they
>  should not be allowed to dictate this. Their "idea" is a bug, and needs to
>  be fixed.

How do you figure this?  The hosts file is ONLY used locally.  If someone is 
looking you up they are using DNS if they don't have you configured 
in "their" hosts file.

Their "idea" might be flaws but it is not bugs.



The adventure of a lifetime.

Linux User #296285
Get Counted

More information about the CentOS mailing list