From nobody Mon Jun 26 08:58:13 2023 X-Original-To: freebsd-questions@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4QqMFp5lKQz4hN3n for ; Mon, 26 Jun 2023 08:58:38 +0000 (UTC) (envelope-from freebsd@vanderzwan.org) Received: from mail2.paztec.nl (mail2.paztec.nl [IPv6:2001:1af8:4700:a116:1::42]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "mail2.paztec.nl", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4QqMFp36QGz4JtX for ; Mon, 26 Jun 2023 08:58:38 +0000 (UTC) (envelope-from freebsd@vanderzwan.org) Authentication-Results: mx1.freebsd.org; none X-Bogosity: No, tests=bogofilter Received: from smtpclient.apple (gaspode [IPv6:2a02:a461:283f:4:0:0:0:22]) (authenticated bits=0) by mail2.paztec.nl (8.17.2/8.17.1) with ESMTPSA id 35Q8wNPm065601 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Jun 2023 10:58:29 +0200 (CEST) (envelope-from freebsd@vanderzwan.org) X-Authentication-Warning: vps4.vanderzwan.org: Host gaspode [IPv6:2a02:a461:283f:4:0:0:0:22] claimed to be smtpclient.apple Content-Type: text/plain; charset=utf-8 List-Id: User questions List-Archive: https://lists.freebsd.org/archives/freebsd-questions List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-questions@freebsd.org X-BeenThere: freebsd-questions@freebsd.org Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.600.7\)) Subject: Re: Using /etc/hosts, not dns From: freebsd@vanderzwan.org In-Reply-To: <846f37ec-c0b3-0b1a-6294-1da6a9260777@Gmail.com> Date: Mon, 26 Jun 2023 10:58:13 +0200 Cc: FreeBSD Questions Mailing List Content-Transfer-Encoding: quoted-printable Message-Id: <1ED24C4A-FABF-4096-970D-4017616FC124@vanderzwan.org> References: <846f37ec-c0b3-0b1a-6294-1da6a9260777@Gmail.com> To: Steven Friedrich X-Mailer: Apple Mail (2.3731.600.7) X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT shortcircuit=ham autolearn=disabled version=4.0.0 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-14) on vps4.vanderzwan.org X-Rspamd-Queue-Id: 4QqMFp36QGz4JtX X-Spamd-Bar: ---- X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:60781, ipnet:2001:1af8::/32, country:NL] X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-ThisMailContainsUnwantedMimeParts: N Hi > On 25 Jun 2023, at 22:51, Steven Friedrich = wrote: >=20 > I have been using /etc/hosts for decades to identify local hosts. I = don't want the complexity of dns for this simple scenario. >=20 > I issue: host slimline > Host slimline not found: 3(NXDOMAIN) >=20 Man page for host command starts with:=20 NAME host - DNS lookup utility So that means it specifically queries DNS, just like nslookup. To use the normal lookup methods configured in /etc/nsswitch.conf you = should use the getent command: NAME getent - get entries from administrative database SYNOPSIS getent database [key ...] So 'getent hosts slimline=E2=80=99 should give you the result you want. Cheers, Paul > Here's the /etc/hosts: >=20 > # $FreeBSD$ > # > # Host Database > # > # This file should contain the addresses and aliases for local hosts = that > # share this file. Replace 'my.domain' below with the domainname of = your > # machine. > # > # In the presence of the domain name service or NIS, this file may > # not be consulted at all; see /etc/nsswitch.conf for the resolution = order. > # > # > ::1 localhost localhost.Friedrich.org > 127.0.0.1 localhost localhost.Friedrich.org > 127.0.1.1 Slimline.Friedrich.org > # > # Imaginary network. > #10.0.0.2 myname.my.domain myname > #10.0.0.3 myfriend.my.domain myfriend > # > # According to RFC 1918, you can use the following IP networks for > # private nets which will never be connected to the Internet: > # > # 10.0.0.0 - 10.255.255.255 > # 172.16.0.0 - 172.31.255.255 > # 192.168.0.0 - 192.168.255.255 > # > # In case you want to be able to connect to the Internet, you need > # real official assigned numbers. Do not try to invent your own = network > # numbers but instead get one from your network provider (if any) or > # from your regional registry (ARIN, APNIC, LACNIC, RIPE NCC, or = AfriNIC.) > # > # local additions > 192.168.1.1 Verizon Internet > 192.168.2.1 RAX80 Netgear router > 192.168.2.2 NAS WDMyCloudEX2Ultra > 192.168.2.3 Brother laser > 192.168.2.4 AppleTV > 192.168.2.5 HP-ENVY > 192.168.2.6 PS5 > 192.168.2.7 PS4 > 192.168.2.9 Slimline.Friedrich.org Slimline > 192.168.2.10 Pi4B > 192.168.2.11 Dell Inspiron3668 MATE Cinnamon Neon Xfce PCLinux > 192.168.2.12 iPhone > 192.168.2.15 XPS XPS-9320 laptop >=20 > and /etc/resolv.conf > # Generated by resolvconf > nameserver 192.168.2.1 >=20 > nameserver 127.0.0.1 > options edns0 >=20 > and /etc/nsswitch.conf >=20 > # > # nsswitch.conf(5) - name service switch configuration file > # $FreeBSD$ > # > group: compat > group_compat: nis > hosts: files dns > netgroup: compat > networks: files > passwd: compat > passwd_compat: nis > shells: files > services: compat > services_compat: nis > protocols: files > rpc: files >=20 > Why won't host lookup slimline in /etc/hosts? > --=20 > FreeBSD slimline.friedrich.org 13.2-RELEASE-p1 FreeBSD 13.2-RELEASE-p1 = GENERIC amd64 > SLIMLINE is GENERIC with unnecessary drivers removed > /usr/ports/.git/HEAD > ref: refs/heads/2023Q2 >=20