How To Direct and Reverse Ip Look Up With Nslookup In Linux and Windows?
nslookup is a network tool using to query DNS to obtain domain name or IP address. The full name of nslookup is “name server lookup” . Nslookup supports interactive and batch mode. Nslookup alternative is dig which uses underlying Operating System libraries.
Syntax is like below.
nslookup [-option] [name | -] [server]
nameis the domain name we want to use
serveris the DNS server we want to use where if not specified the system provided DNS server will be used.
Nslookup can be used in two different modes. One is interactive mode. In order to use nslookup interactively just enter nslookup in the command line.
We will get a shell to enter related commands. Query some domain name.
We get IP address of the domain in interactive mode. To exist interactive mode use
exit command like below.
To get domain name of an IP address is similar to the normal domain name lookup we will just provide the IP address of the target host like below.
$ nslookup 18.104.22.168
Set New DNS Server
By default system provided DNS server is used. This is generally first local cache and then modem configuration where this is set by ISP. DNS server can be changed like below in interactive mode.
MX Lookup or Get Mail Server Domain Name
DNS provides information about domain names. Also mail, sip and other related information about domain can be get by specifying type parameter.
In this example we will try to get mail server domain name
Get Soa Server Domain Name
Soa or DNS server information can be get with soa type queries.
We will get information about mail address first name server etc. from soa request.
Batch mode is second mode. This mode usage is simple command line usage. Just provide command and related arguments. We do not need to enter specific
$ nslookup poftut.com
Specify Record Type
As DNS system have a lot of different type of records we may need to specify a specific record type in batch mode. We will use
-type option and related record type in order to list only specific record type. In this example we will list
mx record type.
$ nslookup -type=mx poftut.com
Query NS Record Of A Domain
The main use case for the
nslookup is querying NS records. NS records provides information about DNS servers of the given domain name. In this example we will list DNS servers of the
$ nslookup -type=ns poftut.com
Query MX Record Of A Domain For Mail Server
MX record is used to list mail servers. We can only list MX records of the given domain with the
mx type. In this example we will list mail servers of the
$ nslookup -type=mx poftut.com
Query SOA Record Of A Domain
SOA or Start Of Authority records provides technical information about the given domain. We can query the domain with the
soa type like below.
$ nslookup -type=soa poftut.com
List All Ns Records Of A Domain
Up to now we have listed DNS related information about domain name one by one. If we need to list all related information provided by a DNS server we can use
any record type.
$ nslookup -type=any poftut.com
Use Different DNS Server
The default behavior of the
nslookup command is using default system provided DNS server. In some cases we may need to change this default DNS server and specify one explicitly. We can add DNS server to the end of the command. In this example we will use
22.214.171.124 as DNS server. We can also specify DNS server domain name.
$ nslookup -type=any poftut.com 126.96.36.199
Specify Different Than Default Port
The default port for DNS services is
53 . If we know that DNS service we will use is using different port we can explicitly specify the port number with the
-port option like below. In this example we will specify the port number
$ nslookup -port=60 poftut.com
While getting related record types there is a lot of transaction and steps which is taken under the hood. If we need to list verbose information and want to know details about
nslookup we can use
-debug option for this.
$ nslookup -debug poftut.com