Applies to: dig and host (bind9-dnsutils or bind-utils) on Linux and macOS, nslookup on Windows, Linux and macOS

DNS lookup commands show which IP address, mail server or text record a domain returns, straight from DNS. They are the quickest way to check a DNS change or find out where a domain points. We ran every example below.

dig (Linux, macOS)

dig example.com                    # full answer with details
dig +short example.com A           # just the IPv4 address
dig +short example.com AAAA        # IPv6
dig +short example.com MX          # mail servers, with priority
dig +short example.com TXT         # SPF, verification records
dig +short example.com NS          # the domain's nameservers
dig +short example.com A @1.1.1.1  # ask a specific DNS server
dig +trace example.com             # follow the lookup from the root servers down

Install it with sudo apt install bind9-dnsutils (Ubuntu, Debian) or sudo dnf install bind-utils (AlmaLinux, Rocky Linux).

nslookup (Windows, Linux, macOS)

nslookup example.com
nslookup -type=MX example.com
nslookup -type=NS example.com
nslookup example.com 8.8.8.8       # ask Google's public DNS

host (Linux, macOS)

host example.com
host -t MX example.com

More examples: useful host command examples.

Common checks

  • Has my DNS change reached the internet? Compare your provider’s nameserver with public resolvers: dig +short example.com A @1.1.1.1 and @8.8.8.8. If they show the new address, your own computer may just need its DNS cache flushed.
  • Which nameservers does my domain use? dig +short example.com NS.
  • Why does my site show a Cloudflare IP? Proxied records return Cloudflare’s addresses, not your server’s.
  • Reverse lookup (IP to name): dig +short -x 203.0.113.10.

Record types explained: wildcard records and SRV records.

Related services

Web hosting

shared hosting on Virtualmin with NVMe storage, free SSL and email.

SSL certificates

DV, OV and wildcard, with free installation help.

Reseller hosting

white-label cPanel hosting for your own clients.

Was this answer helpful?

Still stuck? Open a ticket