media file explorer download upload index folder image licenses menu widget Play Pause profile-settings more dots-two-horizontal dots-two-vertical more-vertical pending google-plus hangouts facebook instagram whatsapp spotify telegram twitter vine renren rss youtube twitch vimeo flickr dribble behance deviantart 500px steam github soundcloud skype reddit linkedin lastfm delicious stackoverflow pinterest xing flattr foursquare yelp World

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 9.11.3-1ubuntu1.12-Ubuntu <<>>
;; 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
;                 IN      A

;; ANSWER SECTION:          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 +short

The above would only return the IP of the domain.

Checking MX record of a domain

user@server:~$ dig MX +short


Checking Name Server of a Domain

user@server:~$ dig NS +short

Checking TXT of a Domain

user@server:~$ dig TXT +short
"v=spf1 a mx ip4: ~all"
"v=spf1 ~all"

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