PDA

View Full Version : Entries in /etc/hosts not resolving



BillGradwohl
6th April 2009, 12:54 AM
Adding entries to /etc/hosts for local resolution doesn't work.

host.conf is correct : order hosts,bind
nsswitch.conf is also correct: hosts: files dns

Yet, I can't get DNS resolution for anything I put into the hosts file.
192.168.168.168 bill.xyz.abc bill

Any ideas?

scottro
6th April 2009, 01:41 AM
Darn, I had this happen the other day, and I'm trying to remember how I fixed it.

Have you rebooted since? I *think* that's what happened--after restarting network services over and over, I gave up, rebooted, and all was good.

Also, just for fun, delete and re-add the line. I know there have been times where I made a typo, for example 192.168.168: bill.xyz.abc (note the colon after the second 168) and didn't realize it until I'd looked at it several times.

BillGradwohl
6th April 2009, 01:07 PM
Darn, I had this happen the other day, and I'm trying to remember how I fixed it.

Have you rebooted since? I *think* that's what happened--after restarting network services over and over, I gave up, rebooted, and all was good.

Also, just for fun, delete and re-add the line. I know there have been times where I made a typo, for example 192.168.168: bill.xyz.abc (note the colon after the second 168) and didn't realize it until I'd looked at it several times.
Tried logging out and in, restarting network services, and rebooting, nothing works.

Even reordered the entries to sort the default IPV6 item at the bottom with all the regular IP's at the top. Still doesn't work.

# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 billlaptop.private.ycc billlaptop localhost.localdomain localhost
192.168.168.106 multimedia.private.ycc multimedia
::1 localhost6.localdomain6 localhost6

Strange part is that a "host localhost" works, but nothing else does.
host check for billlaptop or billlaptop.private.ycc fail.

I know its been years since I tried using this feature of the O/S, but its so simple I can't see what I'm doing wrong.
I don't think its me.

quacked
6th April 2009, 02:15 PM
I just did the IP aliasing thing myself on another disk of this machine with Centos 5 ,,, firstly I ran the commands

ifconfig eth0:1 192.168.0.2 netmask 255.255.255.0

route add -host 192.168.0.2 dev eth0:1

Then I added them to the /etc/hosts Along with that ( in order to keep them after reboot ) I think you have to also add them to the /etc/rc.d/rc.local: settings ( not sure exactly what else will look at them after work today and see )

BillGradwohl
6th April 2009, 02:39 PM
I just did the IP aliasing thing myself on another disk of this machine with Centos 5 ,,, firstly I ran the commands

ifconfig eth0:1 192.168.0.2 netmask 255.255.255.0

route add -host 192.168.0.2 dev eth0:1

Then I added them to the /etc/hosts Along with that ( in order to keep them after reboot ) I think you have to also add them to the /etc/rc.d/rc.local: settings ( not sure exactly what else will look at them after work today and see )
I'm not trying to add an IP alias. I just have 3 boxes I'd like to refer to by name and I'm too lazy to set up a DNS server. That's exactly the situation hosts was supposed to address, at least that's my understanding.

To the best of my knowledge, I'm only supposed to add entries to /etc/hosts. The host.conf file controls the sequence of resolution, but the hosts file itself is the authoritative database.

I'd swear I added entries to hosts many years ago and it worked as I expected. Maybe since then the rules have changed and I'm unaware of them, but searching the man pages and Googling provides no additional enlightenment. Hence my thread here.

quacked
6th April 2009, 03:03 PM
OOps sorry !! that would be the network, files /etc.resolv.conf nsswitch.conf and host.conf ,,,, for the networking ,,, didn't recognize it,,,,, my error ,,, I'll quietly go away now,,,

BillGradwohl
6th April 2009, 03:18 PM
Found : http://www.faqs.org/docs/linux_network/x-087-2-resolv.library.html

Read it and I believe it says that /etc/hosts function is as it always was. Newer O/S releases just added additional layers, but that file is still authoritative for host resolution.

So, I'm stumped.
I believe there's a bug here somewhere but I'm not sure yet. I checked bugzilla, but there was nothing of interest.

pranavprakashmk
17th November 2011, 05:08 PM
Please refer the link http://techyleak.com/2011/11/17/not-resolving-the-entries-in-etchosts/

This really helped me out.