resolver ignores /etc/hosts

I’ve added an entry in /etc/hosts for the host san2.example.com

san1:~ # grep san2 /etc/hosts 192.268.1.2 san2.example.com san2
…and verified that the resolver is configured to check /etc/hosts first (by way of /etc/nsswitch.conf)…

[CODE]san1:~ # grep dns /etc/nsswitch.conf

dns Use DNS (Domain Name Service)

hosts: files dns
networks: files dns[/CODE]
…but the resolver still isn’t resolving the hostname correctly.

san1:~ # ping san2.example.com ping: unknown host san2.example.com
Have I overlooked something? :confused:

Eric Pretorious
Truckee, CA

Hi
192.268 hmmmmmm

Can you ping the ip address? Domain name setup in YaST Network Settings?


Cheers Malcolm °¿° (Linux Counter #276890)
openSUSE 12.2 (x86_64) Kernel 3.4.11-2.16-desktop
up 1 day 10:10, 3 users, load average: 0.09, 0.07, 0.10
CPU Intel i5 CPU M520@2.40GHz | Intel Arrandale GPU

On 12/18/2012 09:03 PM, malcolmlewis wrote:[color=blue]

192.268.1.2 san2.example.com san2

Can you ping the ip address? Domain name setup in YaST Network Settings?[/color]

No no no, this (the bad IP) is the end. Impossible IP addresses will
never be resolved properly and, as you’re pointing out, this is an
impossible IP address.

FWIW: I duplicated the symptom exactly. Putting in a valid IP address
caused things to resolve nicely. I’d guess if you could look at the
resolver stuff in the system you’d see it choke on the bad IP address and
then move on.

Good luck.

[QUOTE=malcolmlewis;10782]Hi
192.268 hmmmmmm

Can you ping the ip address? Domain name setup in YaST Network Settings?[/QUOTE]

Thanks, Malcolm! I fixed the entry in /etc/hosts and the problem went away:

[CODE]san1:~ # grep example /etc/hosts
127.0.0.2 san1.example.com san1
192.168.0.1 san1.example.com san1
192.168.1.2 san2.example.com san2
san1:~ # ping -c3 san1.example.com
PING san1.example.com (127.0.0.2) 56(84) bytes of data.
64 bytes from san1.example.com (127.0.0.2): icmp_seq=1 ttl=64 time=0.042 ms
64 bytes from san1.example.com (127.0.0.2): icmp_seq=2 ttl=64 time=0.020 ms
64 bytes from san1.example.com (127.0.0.2): icmp_seq=3 ttl=64 time=0.022 ms

san1.example.com ping statistics —
3 packets transmitted, 3 received, 0% packet loss, time 1998ms
rtt min/avg/max/mdev = 0.020/0.028/0.042/0.009 ms[/CODE]
Many thanks! :smiley:

Eric Pretorious
Truckee, CA