From owner-freebsd-questions@freebsd.org Fri Aug 3 22:05:36 2018 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 78BE91052C06 for ; Fri, 3 Aug 2018 22:05:36 +0000 (UTC) (envelope-from freebsd-en@lists.vlassakakis.de) Received: from dd14614.kasserver.com (dd14614.kasserver.com [85.13.136.14]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id F35EC7776B for ; Fri, 3 Aug 2018 22:05:35 +0000 (UTC) (envelope-from freebsd-en@lists.vlassakakis.de) Received: from [192.168.3.57] (p5496E1D0.dip0.t-ipconnect.de [84.150.225.208]) by dd14614.kasserver.com (Postfix) with ESMTPSA id 6BAEF43C0743; Sat, 4 Aug 2018 00:05:28 +0200 (CEST) From: Philipp Vlassakakis Message-Id: <00F8C747-1749-4F3D-98AF-B3A980B194FD@lists.vlassakakis.de> Mime-Version: 1.0 (Mac OS X Mail 11.5 \(3445.9.1\)) Subject: Re: name resolution puzzle Date: Sat, 4 Aug 2018 00:05:27 +0200 In-Reply-To: <5cbb1cc0-8e3f-2736-755e-d182abfd90e6@kicp.uchicago.edu> Cc: FreeBSD Mailing List To: Valeri Galtsev References: <5cbb1cc0-8e3f-2736-755e-d182abfd90e6@kicp.uchicago.edu> X-Mailer: Apple Mail (2.3445.9.1) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.27 X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Aug 2018 22:05:36 -0000 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 [=E2=80=A6] open("/etc/resolv.conf",O_RDONLY,0666) =3D 3 (0x3) dig 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 = : >=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"