nslookup command in Linux with Examples

Nslookup (stands for “Name Server Lookup”) is a useful command for getting information from DNS server. It is a network administration tool for querying the Domain Name System (DNS) to obtain domain name or IP address mapping or any other specific DNS record. It is also used to troubleshoot DNS related problems.


nslookup [option]

Options of nslookup command:

  • nslookup google.com :
    nslookup followed by the domain name will display the “A Record” (IP Address) of the domain. Use this command to find the address record for a domain. It queries to domain name servers and get the details.
  • nslookup : Reverse DNS lookup

    You can also do the reverse DNS look-up by providing the IP Address as argument to nslookup.

  • nslookup -type=any google.com : Lookup for any record

    We can also view all the available DNS records using -type=any option.

  • nslookup -type=soa redhat.com : Lookup for an soa record

    SOA record (start of authority), provides the authoritative information about the domain, the e-mail address of the domain admin, the domain serial number, etc…

  • nslookup -type=ns google.com : Lookup for an ns record

    NS (Name Server) record maps a domain name to a list of DNS servers authoritative for that domain. It will output the name serves which are associated with the given domain.

  • nslookup -type=a google.com : Lookup for an a record

    We can also view all the available DNS records for a particular record using -type=a option.

  • nslookup -type=mx google.com : Lookup for an mx record

    MX (Mail Exchange) record maps a domain name to a list of mail exchange servers for that domain. The MX record tells that all the mails sent to “google.com” should be routed to the Mail server in that domain.

  • nslookup -type=txt google.com : Lookup for an txt record

    TXT records are useful for multiple types of records like DKIM, SPF, etc. You can find all TXT records configured for any domain using below command.

Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.