地方エンジニアの学習日記

興味ある技術の雑なメモだったりを書いてくブログ。たまに日記とガジェット紹介。

Linux hostsが反映されてないような現象

hosts編集後にnslookupで名前解決を行ってみたが反映されて無かったので疑問に思って調べた。

理由は簡単でnslookupではどうやらhostsを参照せずにDNSヘ直接問い合わせするためらしい。

トレースをみてみる。確かにhostsへの参照話でdnsへアクセスしていることがわかった。

$ strace -e trace=open nslookup hoge.com
open("/etc/ld.so.cache", O_RDONLY)      = 3
open("/usr/lib64/liblwres.so.80", O_RDONLY) = 3
open("/usr/lib64/libdns.so.81", O_RDONLY) = 3
open("/usr/lib64/libbind9.so.80", O_RDONLY) = 3
open("/usr/lib64/libisccfg.so.82", O_RDONLY) = 3
open("/usr/nhnkrb5/lib/libgssapi_krb5.so.2", O_RDONLY) = 3
open("/usr/lib64/libcrypto.so.10", O_RDONLY) = 3
open("/usr/lib64/libisccc.so.80", O_RDONLY) = 3
open("/usr/lib64/libisc.so.83", O_RDONLY) = 3
open("/lib64/libdl.so.2", O_RDONLY)     = 3
open("/lib64/libcap.so.2", O_RDONLY)    = 3
open("/lib64/libpthread.so.0", O_RDONLY) = 3
open("/usr/lib64/libxml2.so.2", O_RDONLY) = 3
open("/lib64/libz.so.1", O_RDONLY)      = 3
open("/lib64/libm.so.6", O_RDONLY)      = 3
open("/lib64/libidn.so.11", O_RDONLY)   = 3
open("/lib64/libc.so.6", O_RDONLY)      = 3
open("/usr/nhnkrb5/lib/libkrb5.so.3", O_RDONLY) = 3
open("/usr/nhnkrb5/lib/libk5crypto.so.3", O_RDONLY) = 3
open("/lib64/libcom_err.so.2", O_RDONLY) = 3
open("/usr/nhnkrb5/lib/libkrb5support.so.0", O_RDONLY) = 3
open("/lib64/libresolv.so.2", O_RDONLY) = 3
open("/lib64/libattr.so.1", O_RDONLY)   = 3
open("/lib64/libselinux.so.1", O_RDONLY) = 3
open("/proc/filesystems", O_RDONLY)     = 3
open("/etc/pki/tls/legacy-settings", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en_US.UTF-8/libdst.cat", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en_US.UTF-8/LC_MESSAGES/libdst.cat", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en/libdst.cat", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en/LC_MESSAGES/libdst.cat", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en_US.UTF-8/libisc.cat", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en_US.UTF-8/LC_MESSAGES/libisc.cat", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en/libisc.cat", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en/LC_MESSAGES/libisc.cat", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/etc/pki/tls/openssl.cnf", O_RDONLY) = 6
open("/usr/share/locale/en_US.UTF-8/libdns.cat", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en_US.UTF-8/LC_MESSAGES/libdns.cat", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en/libdns.cat", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en/LC_MESSAGES/libdns.cat", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/etc/resolv.conf", O_RDONLY)      = 6
open("/usr/lib/locale/locale-archive", O_RDONLY) = 6