How to Install and Use DIG on Debian 9

The full form of DIG is Domain Information Groper. It is a command line utility for network administrators.The domain name we use such as, etc are possible because of DNS (Domain Name System) servers. DIG is used to query the DNS server, mainly to troubleshoot the DNS server. With DIG, you can check many things like the name server of a particular domain, the mail servers of a particular domain and many more information.

DIG is mainly used by DNS server administrators to verify whether the DNS server is working correctly.

In this article, I will show you how to install DIG on Debian 9 and use DIG. Let’s get started.

Installing DIG on Debian 9:

DIG is a part of dnsutils package. DIG is not installed by default on Debian 9 Stretch. The good news is that it is really easy to install as it is available in the official package repository of Debian 9.

First update the APT package repository cache with the following command:

$ sudo apt update

The APT package repository cache should be updated.

Now install dnsutils package with the following command:

$ sudo apt install dnsutils

Now press y and then press <Enter>.

dnsutils should be installed.

Now to check whether the dig command is available and working correctly, run the following command:

$ dig -v

As you can see, dig is available and working correctly.

In the next sections, I will show you how to use dig.

Basics of dig:

The basic usage of dig command is to lookup a DNS address. By default, on Debian 9, dig uses the /etc/resolv.conf file to find out which DNS server to use.

This is what the /etc/resolv.conf file looks like. To change the DNS server, just change the IP address of the nameserver as marked in the screenshot below. In my case, it is, which is the IP address of my router.

Now to use dig to lookup the DNS information of the DNS name of, run the following command:

$ dig

As you can see, a lot of DNS data is printed on the screen. The marked section shows that the domain name has these IP addresses. A domain name can have multiple IP addresses. It is mainly used for the load balancing purpose.

If you scroll down, you will see the how many milliseconds you needed (Query time) to resolve the domain name In my case, it was 71 milliseconds (msec). It varies depending on your geographical location and the name server you used.

You can also see which name server was used for the query. In my case, it is the name server in my /etc/resolv.conf, which is The port of the DNS server is by default is 53.

The DNS response size or MSG SIZE is 931 bytes as you can see. These are important information that you may need to troubleshoot or test your DNS server configurations.

That’s basically how you use dig. In the next sections, I will show you different things you can do with dig.

Changing Name Server:

When you’re testing your DNS server, you may not want to set it in the /etc/resolv.conf until you know it works for sure. You can tell dig which name server to use as follows:

$ dig @nameserver

NOTE: Replace nameserver with the DNS server that you want dig to use.

Let’s say, we want dig to use the DNS server, then the command would be:

$ dig @

As you can see, the same information is returned. The Query time is now 13 milliseconds, and the SERVER is changed to The MSG SIZE is also 124 bytes.

Dig the MX Records with dig:

You can find the MX records (used in email servers) of a domain name with dig with the following command:

$ dig @ MX

As you can see in the marked section of the screenshot below, these are the email addresses associated with the domain

Dig the NS records using dig:

You can find the name servers associated with the domain name with dig with the following command:

$ dig @ NS

As you can see in the marked section of the screenshot below, these are the name servers associated with the domain

Dig All the Information About a Domain Name with dig:

You can find out all the information about a domain name with dig with the following command:

$ dig @ any

As you can see, all the DNS records (A, AAAA, MX, NS, TXT, SOA etc) for is printed on the screen.

dig Short Output:

All the dig commands we ran earlier printed a lot of information in a nicely formatted text. But if you would rather see a short output, just add +short at the end of your dig command as follows:

$ dig @ any +short

As you can see, only the DNS records are printed. You have to determine which is what in this list as it has no indication as to which is an A record, which is an MX record etc. But if you look closely for a little bit, you will be able to figure out which is what record very easily. For example, all the IPv4 addresses are A records. All the IPv6 addresses are AAAA records. All the lines that start with a number and then a Fully Qualified Domain Name (FQDN) are MX records. All the lines that have text between quotes are TXT records. All the lines that start with ns* are NS records.

A line that has two FQDN and 5 numbers separated by space ( 210455048 900 900 1800 60) is a SOA record.

Getting Help with dig:

dig command has a lot of options. It is out of the scope of this article to show them all. You can run the following command to find out what options are available and what they do:

$ dig -h

dig Help:

So that’s how you install and use dig on Debian 9 Stretch. Thanks for reading this article.

ONET IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, ONET IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

How to Configure dnsmasq on CentOS 7

dnsmasq is a very lightweight and simple DNS server. dnsmasq can be configured to be a DNS server and a DHCP server. In...

Install BIND 9 on Ubuntu and Configure It for Usage

The full form of BIND is Berkeley Internet Name Domain is a DNS server software. A DNS server resolves domain names such...

DNSMasq Ubuntu Tutorial

DNSmasq is a lightweight tool to provide both DNS service and DHCP service for small-scale networks. DNSmasq’s local DNS...
Bài Viết

Bài Viết Mới Cập Nhật

Huớng dẫn dùng proxy cho ios, iphone 2023

Cách gắn set proxy cho điện thoại android, oppo, giả lập android, Ldplayer Bằng Proxydroid

Mua Proxy Socks5 VN Chơi Game Gia Lập Tăng Cường Trải Nghiệm Chơi Game

Mua Proxy Mỹ, Us Nuôi Tài Khoản Etsy, eBay Tìm Hiểu Về Mua Proxy Mỹ tại

Mua Proxy Game – Giải pháp tuyệt vời cho việc chơi game trên mạng mà không bị giới hạn về vị trí địa lý