name resolution puzzle
Philipp Vlassakakis
freebsd-en at lists.vlassakakis.de
Fri Aug 3 22:05:36 UTC 2018
Hi,
As far as I know, neither „nslookup“, nor "host" uses /etc/hosts, regardless if you add „files dns“ to /etc/nsswitch.conf
You can check the entries via "ping".
See truss:
host google.de <http://google.de/>
[…]
open("/etc/resolv.conf",O_RDONLY,0666) = 3 (0x3)
dig google.de <http://google.de/>
[…]
open("/etc/resolv.conf",O_RDONLY,0666) = 3 (0x3)
Regards,
Philipp
> Am 03.08.2018 um 23:41 schrieb Valeri Galtsev <galtsev at kicp.uchicago.edu>:
>
> Dear Experts,
>
> I just noticed some behavior of commands "host" and "nslookup" that puzzles me. Namely, they do not query /etc/hosts file first, but query nameserver instead, even though nsswitch.conf order is "files dns":
>
> $cat /etc/nsswitch.conf | grep hosts
>
> hosts: files dns
>
> $ cat /etc/hosts | grep holometer.uchicago.edu
>
> 128.135.20.84 holometer holometer.uchicago.edu
>
> $ host holometer.uchicago.edu
>
> holometer.uchicago.edu has address 128.135.52.70
>
> $ nslookup holometer.uchicago.edu
>
> Server: 128.135.249.50
> Address: 128.135.249.50#53
>
> Name: holometer.uchicago.edu
> Address: 128.135.52.70
>
>
> So, it appears, that the commands "host" and "nslookup" go directly to DNS server, and do not look into /etc/hosts first which I have expected.
>
> I should mention that other compiled programs do obey the nsswitch.conf query order.
>
>
> Can someone enlighten me on this?
>
>
> The reason I have different IP in /etc/hosts is: I'm building the box to migrate some host to, and I'd like to test some stuff that should work from other machines before I switch DNS records to new IP. So, on these external machines I am trying to have hostname resolve into future IP just by adding it to /etc/hosts.
>
> Thanks.
> Valeri
>
> --
> ++++++++++++++++++++++++++++++++++++++++
> Valeri Galtsev
> Sr System Administrator
> Department of Astronomy and Astrophysics
> Kavli Institute for Cosmological Physics
> University of Chicago
> Phone: 773-702-4247
> ++++++++++++++++++++++++++++++++++++++++
> _______________________________________________
> freebsd-questions at freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "freebsd-questions-unsubscribe at freebsd.org"
More information about the freebsd-questions
mailing list