LightAtom

nslookup Command: Query DNS from the Terminal

Use nslookup to look up a domain's addresses and other DNS records, ask a specific DNS server, and understand what “non-authoritative answer” means.

nslookup apple.com

Look up the addresses for apple.com using your configured DNS server.

beginner5 minNeeds: Terminal

When to use it

Use nslookup to check that a name resolves, see which address it points to, or compare your DNS server's answer with a public resolver's. It's available on macOS, Windows and Linux, which makes it handy when you follow instructions written for any of them.

Steps

  1. Look up a name

    Run nslookup with a domain. The first two lines show which DNS server answered; the rest is the answer.
    nslookup apple.com
  2. Ask for another record type

    Use -type= (or -query=) for MX, TXT, NS, AAAA and others.
    nslookup -type=txt google.com
  3. Ask a specific DNS server

    Add a server at the end. Comparing your own resolver with 1.1.1.1 shows whether your DNS returns something different.
    nslookup apple.com 1.1.1.1
  4. Reverse lookup

    Give an IP address to find its host name (PTR record).
    nslookup 8.8.8.8

Output explained

Server:		192.168.1.1
Address:	192.168.1.1#53

Non-authoritative answer:
Name:	apple.com
Address: 17.253.144.10
  • Server / Address is the DNS server that answered, and #53 the port. On home networks this is usually the router.
  • Non-authoritative answer means the answer came from a resolver's cache, not directly from apple.com's own name servers. That's normal.
  • Name / Address are the results. Large sites often list several addresses.

** server can't find example.invalid: NXDOMAIN means the name doesn't exist.

Options and variations

FlagMeaningExample
-type=XRecord type: A, AAAA, MX, TXT, NS, SOA, CNAME, PTRnslookup -type=ns apple.com
server (last argument)Query this DNS server instead of the defaultnslookup apple.com 8.8.8.8
-debugShow the full response, including TTLsnslookup -debug apple.com
-port=NUse a DNS server on another portnslookup -port=5353 apple.com 127.0.0.1

Common errors

ErrorCauseFix
;; connection timed out; no servers could be reachedThe DNS server isn't answeringTry another server (nslookup apple.com 1.1.1.1); fix your DNS settings.
** server can't find NAME: NXDOMAINThe name doesn't existCheck the spelling or whether the domain expired.
** server can't find NAME: SERVFAILThe resolver couldn't get an answer, often DNSSEC or authoritative server problemsTry another resolver; if all fail, the domain's DNS is broken.

Do it in the app

LightAtom's connections view shows the domain behind each connection your apps make, so you don't have to query names one by one.

Frequently asked questions

How do I use nslookup on a Mac?

Open Terminal and run nslookup followed by a domain, for example nslookup apple.com. Add -type=mx for mail servers or a server address at the end to query a specific resolver.

What does “non-authoritative answer” mean?

The answer came from a caching resolver, not from the domain's own name servers. It's the normal case and doesn't mean the answer is wrong.

Should I use nslookup or dig?

dig shows more detail (TTLs, flags, full sections) and is preferred for troubleshooting. nslookup is simpler and also exists on Windows.

Does nslookup use the same DNS as my Mac?

nslookup asks the server in /etc/resolv.conf, which macOS fills from your network settings. Apps use macOS's resolver, which can also route some names to other servers (for example VPN domains). For an exact match with apps, use dscacheutil -q host -a name apple.com.

LightAtom team

The people who build LightAtom, a network monitor for macOS.