TUTORIAL: How to perform DNS lookup in the command-line

356 0

This post is also available in: Português

One of the common things we do during web development and beyond is to perform DNS lookup on a given domain. Usually, we do this using online services like MX-Toolbox, but, did you know that we can perform DNS lookup right in the command-line? Even better, did you know that this functionality is already available as a native tool in Unix based systems like Ubuntu? In this tutorial i will show you how to do this, and how to enhance it’s output.

The Linux dig command to perform DNS Lookup

On any Unix based system like Ubuntu or Debian, you can just use dig command to perform DNS lookup on any domain.

dig hostmoz.net

The output of this command will be something like the image below:

Just like that we performed our lookup on a domain. If you like, you can pass extra options to the command to reduce it’s verbosity:

dig +noquestion +nostats +nocomments +nocmd hostmoz.net

Enhancing Lookup output with dog.

If you like beautiful outputs on command line, you can use the dog command-line DNS client to perform the same task. dog is not installed by default, but is available for free for all platforms(Windows, Linux, Mac OS) and it’s easy to install. You just need to download the binaries using the Links below and add it to your path. On ubuntu you can copy the dog executable(the one on the bin folder) to /usr/bin. If you are on Windows, you can check this article to know how to had a folder to your path on Windows.

The usage of dog is similar to dig, but by default dog hides all the verbosity and only returns reelevant information. dog also supports the DoT and DoH protocols, and can emit JSON. we can perform a DNS lookup on hostmoz.net by using this command:

dog hostmoz.net A NS MX TXT

The output will be something as pretty as this one:

That’s it, there is no need to relay on online services to perform something as simple as domain lookup 😉

You can download dog for Windows, Linux and Mac OS on the Links below

[download id=”11605″ template=”button” version_id=”11606″]

[download id=”11605″ template=”button” version_id=”11607″]

[download id=”11605″ template=”button” version_id=”11624″]

(Visited 605 times, 1 visits today)

Elisio Leonardo

Elisio Leonardo is an experienced Web Developer, Solutions Architect, Digital Marketing Expert, and content producer with a passion for technology, artificial intelligence, web development, and entertainment. With nearly 15 years of writing engaging content on technology and entertainment, particularly Comic Book Movies, Elisio has become a trusted source of information in the digital landscape.