nslookup

queries DNS servers for hostname and IP information

TLDR

Lookup IP address
$ nslookup [example.com]
Lookup using specific DNS server
$ nslookup [example.com] [8.8.8.8]
Reverse DNS lookup
$ nslookup [192.168.1.1]
Query specific record type
$ nslookup -type=[MX] [example.com]
Query all records
$ nslookup -type=[ANY] [example.com]
Use TCP instead of UDP
$ nslookup -vc [example.com]
Interactive mode
$ nslookup
Debug mode
$ nslookup -debug [example.com]

SYNOPSIS

nslookup [options] [host] [server]

DESCRIPTION

nslookup queries DNS servers for hostname and IP information. It can perform forward and reverse lookups, query specific record types, and diagnose DNS issues.The tool operates in interactive or non-interactive mode, with interactive mode allowing multiple queries.

PARAMETERS

-type=type

Record type (A, AAAA, MX, NS, TXT, SOA, PTR, ANY, CNAME, SRV).
-query=type
Alias for -type.
-class=class
DNS class (IN, CH, HS, ANY). Default is IN.
-debug
Show debug information (full response packets).
-port=port
DNS server port (default 53).
-timeout=seconds
Query timeout.
-retry=n
Number of retries before giving up.
-vc
Use TCP instead of UDP for queries.
-nosearch
Do not append the search list to unqualified names.
-norecurse
Do not request recursive resolution from the server.
-version
Print version and exit.

INTERACTIVE COMMANDS

server name: Set default DNS server (uses current server to resolve it)lserver name: Set default server using the initial serverset type=type: Set query typeset class=class: Set query classset debug / set nodebug: Toggle debug outputset all: Display current option settingsexit: Quit

INSTALL

sudo apt install bind9-dnsutils
sudo apk add bind-tools

CAVEATS

Deprecated in favor of dig. Behavior varies by implementation. Interactive mode differs from command line. Some features implementation-specific.

HISTORY

nslookup was written by Andrew Cherenson at UC Berkeley as part of BIND. While still included in most systems, the BIND documentation recommends using dig for DNS queries due to more consistent behavior.

SEE ALSO

dig(1), host(1), drill(1), getent(1)