Insight: Tutorial To Install And Use dig And nslookup Commands In Linux
In this command tutorial post, we are going to talk about the basic idea and implementation of dig and nslookup commands in a Linux based operating system.
Dig or Domain Information Gopher, is a DNS lookup utility tool. Nslookup is used for handling DNS lookups and dealing with MX records, and the IP address. These days almost all Linux operating systems have both commands installed by default.
Install And Use dig And nslookup Commands In Linux
Just in case if your don’t have dig and nslookup commands installed in your Linux operating system.
Installing dig & nslookup in CentOS/RHEL
Install dig and nslookup using the dnf command.
# dnf install bind-utils
Installing dig & nslookup on Debian / Ubuntu
Run the following command to install dig and nslookup on Ubuntu or debian based operating system.
# apt install dnsutils
Installing dig & nslookup on ArchLinux
# pacman -Sy dnsutils
How To Use dig command:
dig command can be used to query a domain name:
# dig omgfoss.com
The command displays a host of information such as the DNS server, IP address and many more. To get more specific append the +short argument as shown:
# dig omgfoss.com +short
Command to check the MX record of the domain name run.
# dig omgfoss.com MX +short
How to use nslookup command:
Run the following command to retrieve information about a domain name.
# nslookup google.com
Run the command to check the NS record of the domain:
# nslookup -type=ns example.com
Run the command to query the SOA of the domain:
# nslookup -type=soa example.com
Run the command to check the specific NS.
# nslookup example.com ns1.nsexample.com
Run the following command to reverse NS lookup.
# nslookup 10.20.30.40
Run the following command to change the port number for the connection.
# nslookup -port=56 example.com