nslookup command
nslookup (name server lookup) is a tool used to perform DNS lookups in Linux. It is used to display DNS details, such as the IP address of a particular computer, the MX records for a domain or the NS servers of a domain.
nslookup can operate in two modes: interactive and non-interactive. The interactive mode allows you to query name servers for information about various hosts and domains or to print a list of hosts in a domain. The non-interactive mode allows you to print just the name and requested information for a host or domain.
The interactive mode
The interactive mode is entered by typing the nslookup command without any arguments:
To find the IP address of a host, simply type the hostname:
To perform a reverse DNS lookup, enter the IP address of a host:
To display MX records (the mail servers responsible for accepting email messages on behalf of a recipient’s domain), set the DNS query type to MX:
To display NS records, set the DNS query type to NS:
The non-interactive mode
The non-interactive mode is invoked by typing the nslookup command, followed by the name or the IP address of the host to be looked up.
For example, to display the IP address of a hostname, use the following command:
To do a reverse DNS lookup, use the following command:
To display the MX records, use the -query=mx option:
To display the NS records, use the -query=ns option:
To display the SOA record (information about the domain), use the -query=soa option:
To display all the available DNS records, use the -query=any option:
Geek University recommends the following video course to get you started with Linux.