0

We have a host entry on our server in /etc/hosts file. So there is an entry as follows:

10.74.74.76 foo

But on the same machine, via SSH I do the following:

$ host -t a foo
foo.internal.domain.com has address 10.43.55.23

Why is this not referencing the ip in /etc/hosts?

deostroll
  • 155
  • 7
  • Does this answer your question? [Linux command line utility to resolve host names using /etc/hosts first](https://serverfault.com/questions/303716/linux-command-line-utility-to-resolve-host-names-using-etc-hosts-first) – A.B Dec 06 '22 at 19:54

2 Answers2

0

host is a (simple) DNS lookup utility.

Any data in your /etc/hosts file is NOT DNS.

That means that the host command will always query the DNS servers you have configured and it does not honor the typical precedence your system resolver uses in first querying the local hosts database before attempting to resolve the host/FQDN.

diya
  • 1,771
  • 3
  • 14
0

The host command is a DNS lookup utility that always uses DNS as a resolver; never /etc/hosts file.

From host(1) man page:

host is a simple utility for performing DNS lookups.

server is an optional argument which is either the name or IP address of the name server that host should query instead of the server or servers listed in /etc/resolv.conf.

Esa Jokinen
  • 46,944
  • 3
  • 83
  • 129