From owner-freebsd-questions@freebsd.org Fri Aug 3 22:19:08 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 A8D1C1053114 for ; Fri, 3 Aug 2018 22:19:08 +0000 (UTC) (envelope-from derek@computinginnovations.com) Received: from mail.computinginnovations.com (dsl081-227-057.chi1.dsl.speakeasy.net [64.81.227.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mail.computinginnovations.com", Issuer "mail.computinginnovations.com" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 3D6F477EDB for ; Fri, 3 Aug 2018 22:19:07 +0000 (UTC) (envelope-from derek@computinginnovations.com) Received: from [10.20.30.142] (dhcp-10-20-30-142.computinginnovations.com [10.20.30.142]) by mail.computinginnovations.com (8.15.2/8.14.9) with ESMTP id w73LuHVt096764 for ; Fri, 3 Aug 2018 16:56:17 -0500 (CDT) (envelope-from derek@computinginnovations.com) Message-ID: <5B64CF73.4000807@computinginnovations.com> Date: Fri, 03 Aug 2018 16:56:03 -0500 From: Derek Ragona User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130911 Thunderbird/17.0.9 MIME-Version: 1.0 To: freebsd-questions@freebsd.org Subject: Re: name resolution puzzle References: <5cbb1cc0-8e3f-2736-755e-d182abfd90e6@kicp.uchicago.edu> In-Reply-To: <5cbb1cc0-8e3f-2736-755e-d182abfd90e6@kicp.uchicago.edu> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Antivirus: Avast (VPS 180803-8, 08/03/2018), Outbound message X-Antivirus-Status: Clean 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:19:08 -0000 On 8/3/2018 4:41 PM, Valeri Galtsev wrote: > 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 > Do a: man 5 hosts You have the wrong order in your /etc/hosts file you have: 128.135.20.84 holometer holometer.uchicago.edu Should be: 128.135.20.84 holometer.uchicago.edu holometer Also try dig which is more current that nslookup. -Derek --- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus