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
?
답변1
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.
답변2
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
.