What does a minimal /etc/hosts need to contain?
+7
−0
I run an environment that, until recently, did all local name resolution by putting names in /etc/hosts. I'm in the process of replacing that with local DNS. The DNS part works fine, and now I'm trying to clean the old entries out of the /etc/hosts files. It seems to me that, rather than try to sed out bogus entries and hope I didn't miss anything important, it will be simpler to replace each system's file with a clean copy.
What does a minimal working /etc/hosts file need to contain? So far I have this:
127.0.0.1 localhost
# some sources suggest 127.0.1.1 for the fqdn and hostname; it seems to
# me that the local private IP is a better idea, so the machine sees
# the same address for itself that its peers do.
192.168.x.y $HOSTNAME.$DNSDOMAIN $HOSTNAME
# These are in a stock ubuntu install; I am unsure of their universality.
# All machines in question have an ip6 address, but some are
# link-local only.
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
1 answer
+4
−0
Technically, you don't need an /etc/hosts file at all if you have some other form of name resolution available - i.e. DNS.
In practice, what you have will work nicely, and could be cut down to just the 2 localhost entries.
0 comment threads