Re: Using /etc/hosts, not dns

From: Lowell Gilbert <freebsd-questions-local_at_be-well.ilk.org>
Date: Wed, 28 Jun 2023 03:19:10 UTC
Steven Friedrich <freebsdlouisville@gmail.com> writes:

> I've been doing it since 1985.  

Well, yes, of course we edited hosts.txt in 1985. At the time that was
the *sole* directory of hosts and their addresses; the first
implementation of the DNS hadn't been released yet. But we didn't use
the "host" command to look up hostnames, because it wouldn't be invented
until years and years later.

> I just want the host command to work as it did for twenty-odd years.

From a quick look around, Unix-ish machines where "host" returns
information from /etc/hosts are doing it by running a local resolver,
even if just a small one.

> When I was connecting to the Internet with a 2400 baud modem, I
> created my own local caching DNS.  I don't want to do that now.  

Fair enough, but then "host" on other types of machines (including Linux
distributions and, apparently, Apple Macs) generally won't give you
results from /etc/hosts either.

Like I said before, I wouldn't be against having host(1) return some
information that it didn't get from a DNS query. But it should mark that
as such, because "host" is, quite specifially and intentionally, a DNS
lookup tool.

> As a couple posters suggested, I am now using getent ahosts.

Seems reasonable. As another alternative, I tend to rely on what I
consider the ultimate lazy approach: just pinging the hostname. What
people are actually looking for most of the time is just knowing that
they can reach the named host.

Be well.