← Networking
Linux · Networking
How to do a DNS lookup in Linux
Resolve hostnames and check DNS records with dig and host, and see the configured resolvers in /etc/resolv.conf.
Resolve a name to an address and inspect DNS records. dig is the detailed tool; host and getent are quick. getent uses the system full resolution order (files, DNS, LDAP).
# Detailed lookup
dig <host>
# Just the answer
dig +short <host>
# Quick lookup
host <host>
# Resolve the way the system actually does (nsswitch order)
getent hosts <host>
# Which resolvers are configured
cat /etc/resolv.confLinuxdigDNS