Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 4 Aug 2018 00:05:27 +0200
From:      Philipp Vlassakakis <freebsd-en@lists.vlassakakis.de>
To:        Valeri Galtsev <galtsev@kicp.uchicago.edu>
Cc:        FreeBSD Mailing List <freebsd-questions@freebsd.org>
Subject:   Re: name resolution puzzle
Message-ID:  <00F8C747-1749-4F3D-98AF-B3A980B194FD@lists.vlassakakis.de>
In-Reply-To: <5cbb1cc0-8e3f-2736-755e-d182abfd90e6@kicp.uchicago.edu>
References:  <5cbb1cc0-8e3f-2736-755e-d182abfd90e6@kicp.uchicago.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
Hi,

As far as I know, neither =E2=80=9Enslookup=E2=80=9C, nor "host" uses =
/etc/hosts, regardless if you add =E2=80=9Efiles dns=E2=80=9C to =
/etc/nsswitch.conf
You can check the entries via "ping".

See truss:

host google.de <http://google.de/>;
[=E2=80=A6]
open("/etc/resolv.conf",O_RDONLY,0666)		 =3D 3 (0x3)

dig google.de <http://google.de/>;
[=E2=80=A6]
open("/etc/resolv.conf",O_RDONLY,0666)		 =3D 3 (0x3)

Regards,
Philipp

> Am 03.08.2018 um 23:41 schrieb Valeri Galtsev =
<galtsev@kicp.uchicago.edu>:
>=20
> Dear Experts,
>=20
> 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":
>=20
> $cat /etc/nsswitch.conf | grep hosts
>=20
> hosts: files dns
>=20
> $ cat /etc/hosts | grep holometer.uchicago.edu
>=20
> 128.135.20.84	holometer holometer.uchicago.edu
>=20
> $ host holometer.uchicago.edu
>=20
> holometer.uchicago.edu has address 128.135.52.70
>=20
> $ nslookup holometer.uchicago.edu
>=20
> Server:		128.135.249.50
> Address:	128.135.249.50#53
>=20
> Name:	holometer.uchicago.edu
> Address: 128.135.52.70
>=20
>=20
> 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.
>=20
> I should mention that other compiled programs do obey the =
nsswitch.conf query order.
>=20
>=20
> Can someone enlighten me on this?
>=20
>=20
> 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.
>=20
> Thanks.
> Valeri
>=20
> --=20
> ++++++++++++++++++++++++++++++++++++++++
> Valeri Galtsev
> Sr System Administrator
> Department of Astronomy and Astrophysics
> Kavli Institute for Cosmological Physics
> University of Chicago
> Phone: 773-702-4247
> ++++++++++++++++++++++++++++++++++++++++
> _______________________________________________
> freebsd-questions@freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to =
"freebsd-questions-unsubscribe@freebsd.org"




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?00F8C747-1749-4F3D-98AF-B3A980B194FD>