This question already has an answer here:
nslookup can be used to lookup DNS names from the command line. However, they query the names from the DNS server directly, instead of using
nsswitch to resolve host names. This means /etc/hosts and mDNS aren't used.
Is there a command line tool that looks up the name by the standard way (honouring mDNS and /etc/hosts)?
There is a similar question on Ask DIfferent, but it seems to be specific to OS X.