I'm looking for a command that will let me resolve a host name in /etc/hosts
to its corresponding IP address.
nslookup
ignores entries in /etc/hosts
file.
ping
will find entries in /etc/hosts
but is difficult/slow to capture the output.
dnshosts
I'm looking for a command that will let me resolve a host name in /etc/hosts
to its corresponding IP address.
nslookup
ignores entries in /etc/hosts
file.
ping
will find entries in /etc/hosts
but is difficult/slow to capture the output.
Best Answer
On macOS you can use
dscacheutil
, the Directory Service Cache Utility, for this purpose.The output looks like:
(On Linux, the equivalent is
getent
.)