facebook youtube pinterest twitter reddit whatsapp instagram

Installing and Using dig in Ubuntu

dig is an awesome utility for querying DNS name servers. It performs DNS lookups and
displays the answers that are returned from the name server(s) that were queried.

In this guide, you'll learn how to install and use dig in GNU/Linux, this command can be used to troubleshoot DNS problems.

To install dig in Ubuntu, you simply use the following command:

sudo apt install dnsutils

Verify the dig installation by running dig -v

To query a domain name, you use the following command (I would be using devsrealm as an example):

dig devsrealm.com


; <<>> DiG 9.11.3-1ubuntu1.12-Ubuntu <<>> devsrealm.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 25063
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

; EDNS: version: 0, flags:; udp: 65494
;devsrealm.com.                 IN      A

devsrealm.com.          299     IN      A

;; Query time: 870 msec
;; WHEN: Thu Jul 02 19:04:15 UTC 2020
;; MSG SIZE  rcvd: 58

You can see it returned the result, to get only the IP of the domain you are querying, you can use:

dig devsrealm.com +short

The above would only return the IP of the domain.

Checking MX record of a domain

user@server:~$ dig devsrealm.com MX +short

10 mxa.mailgun.org.
10 mxb.mailgun.org.

Checking Name Server of a Domain

user@server:~$ dig devsrealm.com NS +short

Checking TXT of a Domain

user@server:~$ dig devsrealm.com TXT +short
"v=spf1 a mx ip4: ~all"
"v=spf1 include:mailgun.org ~all"

You can read more using the man page, it can really be a lifesaver if you are troubleshooting DNS related problem.


Related Post(s)

  • Send Mail with Attachment Using Mutt in GNU/Linux

    Mutt is a powerful text&#x2d;based mail client for Unix/Linux operating systems. It features color support, message threading, MIME support...

  • Using Pageant To Automatically Authenticate SSH key in Putty

    I can't count how many times I have typed my ssh key passphrase whenever my ssh connection times out, it is so annoying and repetitive. Well, thanks to the putty pageant, you can do that seamlessly.

  • Installing WP-CLI In a GNU/Linux Server

    WP-CLI is a command-line interface for WordPress. It can also be used with ClassicPress, as they are no differences in their usage, maybe just minimal if you are updating or downloading new ClassicPr

  • Installing and Running Rclone Mount As a Windows Service

    I previously wrote a guide on how to mount and unmount rclone in Linux, in this guide, I’ll walk you through on how to do the same on a windows system. Step 1: Download Rclone First, go to rclone d

  • How To Send Mail To Multiple Addresses Using (mailx)

    In this guide, you'll learn a couple of ways you can send mail to multiple addresses using mailx. mailx is a utility program for sending and receiving mail. I assume you already have mailx command, i

  • Mounting and Unmounting Cloud Storage With (Rclone) in GNU/Linux

    Ever wondered if you could mount your preferred cloud storage as a virtual drive on your system? Thanks to Rclone, you can mount and access different kinds of cloud storage from a file manager, I'll