We often check the DNS information of an IP or domain name at work to see which machine the current IP is bound to, or if the current domain name resolves properly. This is where the nslookup command comes into play.

Command Details

The nslookup command is mainly used to query the DNS information of a domain name. nslookup has two working modes: “interactive mode” and “non-interactive mode”. Enter nslookup directly in the command line, and you will enter the interactive mode without entering any parameters.

Full spelling of the command

nslookup = query Internet name server interactively

Syntax format

1
nslookup [parameter] [domain name]

Parameter Description

  • set type=a: Set query domain name A record.
  • set type=mx: set query domain mail exchange record.

Example

  1. in non-interactive mode to query the basic information of the domain name.

    1
    2
    3
    4
    5
    6
    7
    
    nslookup yeqiongzhou.com
    
    Server:         100.100.36.1
    Address:        100.100.36.1#53
    Non-authoritative answer:
    Name:   yeqiongzhou.com
    Address: 185.199.108.153
    
  2. Enter the interactive mode to query the domain name information.

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    
    # nslookup
    > set type=mx
    > yeqiongzhou.com
    Server:         100.100.36.1
    Address:        100.100.36.1#53
    Non-authoritative answer:
    yeqiongzhou.com mail exchanger = 10 mxbiz2.qq.com.
    yeqiongzhou.com mail exchanger = 5 mxbiz1.qq.com.
    Authoritative answers can be found from:
    > exit
    

Tips

Before using nslookup, make sure you have it installed. nslookup is a command in the bind-utils package.