How to Use the Nslookup Command

Learn how to use nslookup on Windows, macOS, and Linux to query DNS records, troubleshoot name resolution, and verify configuration.

Nslookup Basics and When to Use It

nslookup is a classic command-line tool for querying DNS servers. It lets you ask specific questions about hostnames, IP addresses, and record types, which is invaluable when websites fail to load or you are configuring DNS for a domain. Unlike a browser, nslookup bypasses caching layers and shows you exactly what a DNS server returns.

You can use nslookup in two modes: noninteractive, where you run a single command and see the result, or interactive, where you enter several queries in a row. For most quick checks, the noninteractive form is easier.

Command examples
Windows — Basic nslookup examples

Run these in Command Prompt or PowerShell.

nslookup example.com
nslookup 8.8.8.8
nslookup -type=MX example.com
nslookup -type=TXT example.com
        
macOS — Query specific record types

Use Terminal for these queries.

nslookup example.com
nslookup -query=A example.com
nslookup -query=AAAA example.com
nslookup -query=NS example.com
        

Advanced Nslookup Usage and Custom Servers

By default, nslookup queries the DNS server configured on your system, usually provided by your router or ISP. You can explicitly choose another resolver, such as a public DNS service, to compare answers and detect misconfigurations or caching issues.

For repetitive work, nslookup’s interactive mode lets you set default options once and then issue multiple queries. However, many administrators now prefer dig because it exposes more protocol details. Learning nslookup is still valuable because it is installed by default on many systems.

Command examples
Windows — Use a different DNS resolver

Override your default DNS server for a single lookup.

nslookup example.com 1.1.1.1      # Use Cloudflare DNS
nslookup example.com 8.8.8.8      # Use Google Public DNS
        
macOS — Interactive mode basics

Enter interactive mode, then change query types.

nslookup
> server 9.9.9.9
> set type=MX
> example.com
> exit