Linked List : FOSS Tools to Query DNS

If you are a web developer, or if your work involves anything involving the Internet, you can't escape DNS. DNS is Internet's addressing system. When you change domain settings or when you want to debug connections. You often end up querying DNS. Here are my go-to tools that I use to query DNS.

DIG

DIG is a Unix tool to query the DNS systems for various values. It's almost always present on all *nix systems. And very easy to use. Let's say you have set up your DNS to point to a web server IP. Now you want to know if the look-up returns the value. You can do that using

thej@uma:~/code$ dig thejeshgn.com

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

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;thejeshgn.com.			IN	A

;; ANSWER SECTION:
thejeshgn.com.		1001	IN	A	184.168.47.225

;; Query time: 1 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Wed Apr 07 18:22:04 IST 2021
;; MSG SIZE  rcvd: 58

Let's say you want to get your MX records to see if the email is setup properly

thej@uma:~/code$ dig thejeshgn.com MX

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

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;thejeshgn.com.			IN	MX

;; ANSWER SECTION:
thejeshgn.com.		10722	IN	MX	30 alt2.aspmx.l.google.com.
thejeshgn.com.		10722	IN	MX	50 aspmx3.googlemail.com.
thejeshgn.com.		10722	IN	MX	20 alt1.aspmx.l.google.com.
thejeshgn.com.		10722	IN	MX	40 aspmx2.googlemail.com.
thejeshgn.com.		10722	IN	MX	10 aspmx.l.google.com.

;; Query time: 3 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Wed Apr 07 18:22:55 IST 2021
;; MSG SIZE  rcvd: 172

It has many many many features. Look at the man page for it.

DOG

dog is an open-source DNS client for the command-line. It has colourful output, supports the DoT and DoH protocols, and can emit JSON.

dog

It's a FOSS tool. It supports JSON output so you can say pipe the output to a CouchDB. It also supports DNS-over-TLS an DNS-over-HTTPS, the more modern protocol to query DNS. There is also Doggo, which is very similar and also FOSS.

thej@uma:~/code$ dog thejeshgn.com --json | jq 
{
  "responses": [
    {
      "queries": [
        {
          "name": "thejeshgn.com.",
          "class": "IN",
          "type": "A"
        }
      ],
      "answers": [
        {
          "name": "thejeshgn.com.",
          "class": "IN",
          "ttl": 35,
          "type": "A",
          "data": {
            "address": "184.168.47.225"
          }
        }
      ],
      "authorities": [],
      "additionals": []
    }
  ]
}

You can combine with jq to filter JSON and manipulate the results for your display.