I am running OpenSuSE Leap 42.3 on a machine with 2 NICs. I am also running a Bind DNS server on the same system. I did an experiment in order to assign a unique hostname to each of the NIC interface cards by simply editing my /etc/hosts file as shown below:
bigbang:/etc # cat /etc/hosts
127.0.0.1 localhost
# added for each nic
192.168.10.100 bigbangInternal.mydomainname.com bigbangInternal
10.10.10.100 bigbangExternal.mydomainname.com bigbangExternal
::1 localhost ipv6-localhost ipv6-loopback
fe00::0 ipv6-localnet
ff00::0 ipv6-mcastprefix
ff02::1 ipv6-allnodes
ff02::2 ipv6-allrouters
ff02::3 ipv6-allhosts
My host.conf file is configured to look at the hosts file first when resolving names:
bigbang:/etc # cat /etc/host.conf
## file comments deleted for brevity...
order hosts, bind
multi on
My nsswitch.conf file is also configured to look at the hosts file first when resolving names:
bigbang:/etc # cat /etc/nsswitch.conf
## file comments deleted for brevity...
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
After editing the /etc/hosts file I flushed the name service cache:
bigbang:/etc # systemctl restart nscd.service
and when I test things out I get the following “surprising” results which appear at first glance to show that the name resolving order specified in nsswitch.conf is not being honored. But something else even deeper is going on as well that really has me baffled:
bigbang:/etc # ping bigbangInternal
ping: unknown host bigbangInternal
??? didn’t expect that!
bigbang:/etc # getent hosts
127.0.0.1 localhost
192.168.10.100 bigbangInternal.mydomainname.com bigbangInternal
10.10.10.100 bigbangExternal.mydomainname.com bigbangExternal
that looks good…
bigbang:/etc # getent hosts localhost
::1 localhost
??? I am a bit surprised by this as I did not enable IPv6 addresses in YaST
bigbang:/etc # getent hosts bigbangInternal
bigbang:/etc # getent hosts bigbangInternal.mydomainname.com
??? no response! why not?
bigbang:/etc # getent hosts 10.10.10.100
10.10.10.100 mydomainname.com
??? huh? why did I get my dns domain name?
bigbang:/etc # getent hosts 192.168.10.100
??? no response!
My guess is that these attempts to resolve these names and ip addresses is being done by my bind dns server and not by looking things up in the /etc/hosts file. But I don’t understand why given that I am specifying that the order of lookup is to be done first via the /etc/hosts file and then by the bind dns server if the lookup in the hosts file fails. What am I missing and/or not understanding?
Thanks in advance for any guidance/clues as to why I am seeing these results.
Marc…