Hosts file is not being read

First: I have looked up my question on many sites on the Internet. I’ve even seen a couple that claimed to have found the ‘fix’… but they didn’t say what it was! :frowning:

I have set a few IPs that I use frequently into the hosts file - to save the 3-4 seconds resolution time on each lookup.

My problem is simply that the hosts file is not being read. Pinging always resolves via DNS. Anyone know where the problem lies?

I have checked the nsswitch.conf. All appears to be OK…

passwd: compat
group: compat

hosts: files mdns_minimal [NOTFOUND=return] dns
networks: files dns

services: files
protocols: files
rpc: files
ethers: files
netmasks: files
netgroup: files nis
publickey: files

bootparams: files
automount: files nis
aliases: files

Excerpt from hosts file…

173.194.112.149 mail.google.com googlemail.l.google.com
173.194.112.150 mail.google.com googlemail.l.google.com
173.194.113.85 googlemail.com
173.194.113.86 googlemail.com
213.57.23.15 google.com plus.google.com support.google.com www3.l.google.com
213.57.23.19 google.com plus.google.com support.google.com www3.l.google.com

Thanks for your help!

You say you think that it always resolves using the DNS servers, but you do not show us any evidence. How do you come to that conclusion?

BTW, you tried to make the computer texts in your post better readable by putting your whole post into a fixed font. There is no need for that. It is more pleasing to our eyes when you write yoor “story” in the default font of the forums and then copy/past your computer text between CODE tags. You get the CODE tags by clicking on the # bar in the post editor.
Also, when applicable, please copy/paste from the terminal screen not only the output, but also the prompt, the command, the output and the next prompt. Then we can see how you got what you want to show and you do not have to explain that. Example:

henk@boven:~> grep -v '^#' /etc/nsswitch.conf


passwd: compat
group:  compat

hosts:          files mdns_minimal [NOTFOUND=return] dns
networks:       files dns

services:       files
protocols:      files
rpc:            files
ethers:         files
netmasks:       files
netgroup:       files nis
publickey:      files

bootparams:     files
automount:      files nis
aliases:        files


henk@boven:~>
  1. You didn’t really describe exactly what your test was.
  2. After making Host file changes, did you flush your local cache?
nscd restart

TSU

Sorry, “nscd restart” doesn’t work on openSUSE.

This should work

nscd -K && nscd

TSU

On 2013-09-12 19:16, tsu2 wrote:
> Sorry, “nscd restart” doesn’t work on openSUSE.

prepend “rc”. It does work.


Cheers / Saludos,

Carlos E. R.
(from 12.3 x86_64 “Dartmouth” at Telcontar)