The main use of nslookup is to help with any DNS issues you may have. You can use it to find the IP address of a host, find the domain name of an IP address, or find mail servers on a domain. This tool can be used in two modes.

  1. An interactive
  2. Non-interactive mode

The Interactive mode is used to query DNS-Server about various domains and hosts. Non-Interactive mode is used to query about information of a domain or host.

Interactive mode In nslookup command in Linux

Example1: You can enter to the interactive mode by using the following command

#nslookup

If you only know the hostname of a host and you need to find the ip address of that host, type the hostname

Example2: Similar to the previous command, you can type the ip address to find out the domain using reverse domain lookup

Example3: You can set the DNS query type to NS to display the NS records only.

>set type=ns
><URL>

Example4: Query only Mail servers. To do that set the DNS query type to MX to display the MX records

>set type=mx
><URL>

The non-interactive mode in nslookup command

The non-interactive mode is invoked by typing the nslookup command, followed by the name, domain or the IP address of the host/network to be looked up.

Example 5: Run the following command to query SOA record

#nslookup -type=soa <URL>

Example6: You can enable Debug mode to display verbose output

#nslookup -debug <URL>

Example 7: Use the following command to query all available dns records:

#nslookup -query=any <URL>

Example 8: Instead of using default DNS server’s for querying, you can also specify a particular name server to resolve the domain name.

#nslookup <URL> <name_server_URL>

Example 9: You can use a specific port instead of using the default port 53 using the following command

#nslookup set port=<port_number> <URL>

Example 10: By default, NSlookup default timeout is set to 5 seconds. You can change it by using the following command

#nslookup -timeout=<number_of_seconds> <URL>

The following two tabs change content below.
Ruwantha Nissanka is a Professional Cyber Security Engineer from Sri lanka with having a demonstrated history of providing cyber security services for multiple organizations in Sri Lanka. He is a positive person who wants to believe the best in others and he likes to help, encourage people and make them feel good.