Just want to note here, that I bumped in to this whole problem while installing proxmox pve-cluster and pve-cluster did also ignore /etc/hosts.
Thanks guys for your help. On Sep 6, 2014 11:26 AM, "Bob Proulx" <b...@proulx.com> wrote: > Podrigal, Aron wrote: > > ok, a fresh install of debian 7.6, here is my settings, I don't have > > libnss-myhostname > > installed yet > > It shouldn't be *required*. It is one of those optional features that > some people want and others do not want. It is useful. But for > example I don't have it installed either. Because it creates an > emulation layer it can cause problems. The answer is, "It depends." > > > root@test1:~# cat /etc/hosts > > 127.0.0.1 localhost > > 127.0.1.1 test1.test.com test1 > > > > # The following lines are desirable for IPv6 capable hosts > > ::1 localhost ip6-localhost ip6-loopback > > ff02::1 ip6-allnodes > > ff02::2 ip6-allrouters > > Hmm... You are actually the owner of test.com? Or did you just > double up using their domain? People often type in random domains > there thinking they can do that but really they shouldn't because > someone else owns that domain. If you own test.com then that is all > good. If you don't then you shouldn't use it. > > > root@test1:~# getent hosts $(hostname) > > 127.0.1.1 test1.test.com test1 > > Good. > > > root@test1:~# cat /etc/nsswitch.conf > > ... > > hosts: files dns > > Good. Look for data from local files first. Fall through and ask DNS > for the name if not found locally. > > That is what "normal" things will do. Normal things like "ping foo" > and "ssh foo" and http://foo/ and so forth. Not DNS specific things > such as host or dig. > > > root@test1:~# host -v $(hostname) > > Trying "test1" > > Host test1 not found: 3(NXDOMAIN) > > Received 98 bytes from 8.8.8.8#53 in 14 ms > > The host, dig and nslookup and those commands are DNS commands. As > Reco and Brian noted DNS is a network service and separate from the > local file configuration. Your local files are fine. When you try to > do a DNS lookup from your DNS nameserver it is failing to respond with > an appropriate localhost entry. > > > Clearly, it skips /etc/hosts entries. > > Right. That is what it is supposed to do. DNS doesn't use > /etc/hosts. DNS is a network service. The nsswitch is used to > indicate that normal system processes that use libc will look through > files first and then dns. But 'host' is a dns specific lookup. It by > design of being a dns lookup tool only looks in dns. > > > After digging around, I noticed, that I had always setup DNS records for > my > > hosts prior to doing the installations, which caused me the confusion on > > what was happening. I thought that the looking up my hostname resolves > > correctly by getting the ip from /etc/hosts, which I was wrong. > > > > So yes, host does not look in /etc/hosts by default. > > That is correct. > > But there is a problem. There is a problem with your network DNS > configuration. Every domain zone should have a localhost configured > for it. Therefore when you do a host lookup of localhost in DNS it > should return the zone's localhost record. > > $ host localhost > localhost.proulx.com has address 127.0.0.1 > > That is because my proulx.com zone has a localhost record in it. > > localhost IN A 127.0.0.1 > > If you are searching test.com for localhost.test.com then you should > be returning a record from that domain. Which is currently > misconfigured to be something other than 127.* so you shouldn't use it > either. > > In summary, use your real domain name and not test.com. In your DNS > zone ensure you have a localhost record. If you squat on someone > else's domain then you are at the mercy of their configuration which > you don't want. > > Bob >