Re: Using /etc/hosts, not dns
- Reply: Steven Friedrich : "Re: Using /etc/hosts, not dns"
- In reply to: Steven Friedrich : "Using /etc/hosts, not dns"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 26 Jun 2023 08:58:13 UTC
Hi > On 25 Jun 2023, at 22:51, Steven Friedrich <freebsdlouisville@gmail.com> wrote: > > I have been using /etc/hosts for decades to identify local hosts. I don't want the complexity of dns for this simple scenario. > > I issue: host slimline > Host slimline not found: 3(NXDOMAIN) > Man page for host command starts with: 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’ should give you the result you want. Cheers, Paul > Here's the /etc/hosts: > > # $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 > > and /etc/resolv.conf > # Generated by resolvconf > nameserver 192.168.2.1 > > nameserver 127.0.0.1 > options edns0 > > and /etc/nsswitch.conf > > # > # 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 > > Why won't host lookup slimline in /etc/hosts? > -- > 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 >