Re: Using /etc/hosts, not dns

From: Lowell Gilbert <freebsd-questions-local_at_be-well.ilk.org>
Date: Tue, 27 Jun 2023 01:38:26 UTC
Steve O'Hara-Smith <steve@sohara.org> writes:

> On Mon, 26 Jun 2023 14:35:06 -0400
> Steven Friedrich <freebsdlouisville@gmail.com> wrote:
>
>> Correct, Linux still works.  After all these years and my extensive Unix 
>> experience, I am abandoning FreeBSD.  You have completely abandoned 
>> common sense.
>
> 	The host command has been specified to only use DNS for as long as
> it has existed. If there's an implementation of host that reads the hosts
> file then it is that implementation which is anomalous not the FreeBSD one.

And it's documented to be a DNS lookup utility on my (Ubuntu) Linux
system also.

But that version also first gives a result from /etc/hosts, in the form: 
	theserver has address 172.30.250.1

It looks like the Ubuntu host(1) program comes from ISC, just like the
one in the bind-tools package on FreeBSD, but it's been modified to
check /etc/hosts as well. I suspect that Linux distributions vary on
this, although I'm too lazy to go around checking.

I don't think this is necessarily a bad piece of functionality, but
given that host(1) is specifically a DNS lookup tool, it should
definitely indicate when it is giving results that don't come from doing
a DNS lookup. As far as I know, "host" is not a POSIX standard command,
so it can be anything its host (no pun intended) system wants it to be.
However, all of the versions I can find (easily) either come from the
ISC codebase or are trying to imitate ISC, so I think it's only
reasonable to assume that its results reflect a DNS query.

My take is that what the original poster expects isn't unreasonable, but
people with that superficial an understanding of how things work
probably shouldn't be editing /etc/hosts in the first place.

Be well.