Search code examples
linuxdnsnameserversnslookupubuntu-15.10

ping, ssh, ... uses different IP than one resolved by nslookup, host,


After new install of Ubuntu15.10 my commands(ping, ssh, ...) are using different IP address than one resolved by nslookup, host, dig, ... How could this happen?

user@ubuntu-15-10:~$ nslookup foobar.com
 Server:        127.0.1.1
 Address:   127.0.1.1#53

 Non-authoritative answer:
 foobar.com canonical name = foobar.homeip.net.
 Name:  foobar.homeip.net
 Address: 12.34.56.78

user@ubuntu-15-10:~$ host foobar.com
 foobar.com is an alias for foobar.homeip.net.
 foobar.homeip.net has address 12.34.56.78

user@ubuntu-15-10:~$ ping foobar.com
 PING foobar.com (192.168.1.3) 56(84) bytes of data.
 64 bytes from foobar.localdomain.home (192.168.1.3): icmp_seq=1 ttl=64 time=0.245 ms
 64 bytes from foobar.localdomain.home (192.168.1.3): icmp_seq=2 ttl=64 time=0.285 ms
 64 bytes from foobar.localdomain.home (192.168.1.3): icmp_seq=3 ttl=64 time=0.269 ms
 ^C
 --- foobar.com ping statistics ---
 3 packets transmitted, 3 received, 0% packet loss, time 2000ms
 rtt min/avg/max/mdev = 0.245/0.266/0.285/0.021 ms

user@ubuntu-15-10:~$

My /etc/resolv.conf

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 127.0.1.1
search localdomain.home

My /etc/nsswitch.conf

# /etc/nsswitch.conf
#
# Example configuration of GNU Name Service Switch functionality.
# If you have the `glibc-doc-reference' and `info' packages installed, try:
# `info libc "Name Service Switch"' for information about this file.

passwd:         compat
group:          compat
shadow:         compat

hosts:          files mdns4_minimal [NOTFOUND=return] wins dns
networks:       files

protocols:      db files
services:       db files
ethers:         db files
rpc:            db files

netgroup:       nis

No entry for foobar.com in /etc/hosts

Anyone any idea?


Solution

  • I found a fix myslef after some investigation... Problem was in /etc/nsswitch.conf: at "hosts" line: "dns" entry should be before "wins" entry... I don't understand what's behind, however now it works like expected