Saturday, October 5, 2024

Host, Dig

I tend to use “dig” for DNS lookups, but it’s more habit than anything else. The main page for host says “host is a simple utility for performing DNS lookup” while dig’s brags “Most DNS administrators use dig to troubleshoot DNS problems because of its flexibility, ease of use and clarity of output. Other lookup tools tend to have less functionality than dig.”

Well, yes, dig does perhaps have more power than host, but the need for that power doesn’t come up all that often and host is both easier to use and more direct with its output. For getting an ip address from a hostname, the usage is the same, either “dig hostname” or “host hostname”, but “host” returns only the ip address. Almost always, that’s all I care about:

$ host aplawrence.com
aplawrence.com has address 64.226.42.29
$ dig aplawrence.com

; > DiG 9.2.2 > aplawrence.com
;; global options: printcmd
;; Got answer:
;; ->>HEADER> DiG 9.2.2 >>> -x 67.28.113.10
;; global options: printcmd
;; Got answer:
;; ->>HEADER

Keep in mind that both of these are actually looking for a PTR record.

Looking up MX records is easy with either tool:

$ dig pcunix.com mx

; > DiG 9.2.2 > pcunix.com mx
;; global options: printcmd
;; Got answer:
;; ->>HEADER

But again "host" just gives us the bare facts:

$ host -t MX pcunix.com
pcunix.com mail is handled by 10 64.226.42.29.

Another common use is to look up using some other DNS server. I'll do this to check for propagation progress and sometimes for errors:

$ dig @NS40.WORLDNIC.com yahoo.com
..(typical dig output)
$ host www.yahoo.com NS40.WORLDNIC.com
Using domain server:
Name: NS40.WORLDNIC.com
Address: 216.168.225.170#53
Aliases:

Again, host tells us less, but more directly gives what we usually want to see.

There are more options for both commands; this only covered the basic usage.

*Originally published at APLawrence.com

A.P. Lawrence provides SCO Unix and Linux consulting services http://www.pcunix.com

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles

Mid cap stocks : the unexpected beneficiary of rate cuts | finoracle. Топлоизолационни материали на austrotherm stoev atmasutra mindcare.