DNS Lookup in Linux – dig, nslookup and host Commands

DNSUtils is a useful package for quickly checking and viewing DNS information from the Linux terminal for domains and servers. It includes simple commands like “dig”, “nslookup”, and “host” that you can use to find IP addresses, DNS records, mail servers, and nameservers. It is also useful for checking and troubleshooting domain DNS settings quickly and easily.

Features of DNSUtils Package:

  • Check IPv4 and IPv6 addresses.
  • View MX, NS, TXT, and SOA records.
  • Perform reverse DNS lookups.
  • Query a specific DNS server.
  • Trace DNS resolution.
  • Check DNSSEC information.
  • Get quick DNS results from the terminal.
  • Use dig, nslookup, and host.

What is DNSUtils?

DNSUtils is a collection of useful DNS commands available on Linux. It lets you look up domain names, IP addresses, DNS records, and name servers from the terminal. It includes commands like “dig”, “nslookup”, and “host” for different types of DNS queries.

  • dig – Used for detailed DNS queries and DNS troubleshooting.
  • nslookup – Used for simple domain and DNS record lookups.
  • host – Used for quick DNS lookups and IP address checks.

DNSUtils Installation Command

Below are the simple commands to install DNSUtils on Debian and Ubuntu-based Linux systems.

First, Update packages.

apt update

Now install dnsutils using the apt package manager.

apt install dnsutils -y

Check if dig is installed.

dig -v

DNSUtils and its tools are now installed and ready to use.

Dnsutils Usage Commands

Below are some useful DNSUtils commands to check domain names, IP addresses, DNS records, and other DNS information from the Linux terminal.

Check the A record of a domain.

dig example.com

Show only the IP address.

dig example.com +short

Check the IPv6 address.

dig example.com AAAA

Check the MX records.

dig example.com MX

Check the NS records.

dig example.com NS

Check the TXT records.

dig example.com TXT

Check the SOA record.

dig example.com SOA

Perform a reverse DNS lookup.

dig -x 8.8.8.8

Use a specific DNS server.

dig @8.8.8.8 example.com

Check MX records using a specific DNS server.

dig @8.8.8.8 example.com MX

Show only the answer section.

dig example.com +noall +answer

Show DNS query statistics.

dig example.com +stats

Show the question and answer sections.

dig example.com +question +answer

Check DNSSEC information.

dig example.com +dnssec

Trace the DNS resolution.

dig example.com +trace

Force the query to use IPv4.

dig -4 example.com

Force the query to use IPv6.

dig -6 example.com

Use TCP for the DNS query.

dig +tcp example.com

Set the DNS query timeout to 10 seconds.

dig example.com +timeout=10

Set the number of DNS query attempts to 5.

dig example.com +tries=5

Show the output in YAML format.

dig example.com +yaml

Check the installed dig version.

dig -v

Show the dig help menu.

dig -h

nslookup Commands

Check the DNS information of a domain.

nslookup example.com

Use a specific DNS server for the lookup.

nslookup example.com 8.8.8.8

Start the interactive nslookup mode.

nslookup

Check the MX records.

nslookup -type=MX example.com

Check the NS records.

nslookup -type=NS example.com

Check the TXT records.

nslookup -type=TXT example.com

host Commands

Check the IP address of a domain.

host example.com

Show detailed DNS information.

host -a example.com

Check the A record.

host -t A example.com

Check the AAAA record.

host -t AAAA example.com

Check the MX records.

host -t MX example.com

Check the NS records.

host -t NS example.com

Check the TXT records.

host -t TXT example.com

Perform a reverse DNS lookup.

host 8.8.8.8

Using these commands, you can quickly check DNS records, find IP addresses, and troubleshoot common DNS issues.

Overview

DNSUtils provides simple command-line tools for checking and troubleshooting DNS information. dig is useful for detailed DNS queries, while nslookup and host are useful for quick DNS lookups. These commands are also useful for learning how domain names connect to IP addresses and other DNS services.

SHARE THIS POST: