dig

using dig is very simple, and can provide some rather useful information about a domain.

useful for finding out where a domain may be hosted, you can also see nameservers, mx records, ttl.

the standard output is quite full of information:

[code gutter=”false”]
dig tizardsbriefcase.com

; <<>> DiG 9.8.1-P1 <<>> tizardsbriefcase.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 44544
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1

;; QUESTION SECTION:
;tizardsbriefcase.com.        IN    A

;; ANSWER SECTION:
tizardsbriefcase.com.    18788    IN    A    46.32.230.161

;; AUTHORITY SECTION:
tizardsbriefcase.com.    18788    IN    NS    ns.tizardsbriefcase.com.

;; ADDITIONAL SECTION:
ns.tizardsbriefcase.com. 18788    IN    A    46.32.230.161

;; Query time: 49 msec
;; SERVER: 192.168.0.1#53(192.168.0.1)
;; WHEN: Mon Aug 27 15:50:22 2012
;; MSG SIZE  rcvd: 87
[/code]

but sometimes you only want the raw essentials. tidying it up is easy, using +noall to turn off all output, then use +answer to only get the important part:

[code gutter=”false”]
dig tizardsbriefcase.com any +noall +answer

; <<>> DiG 9.8.1-P1 <<>> tizardsbriefcase.com any +noall +answer
;; global options: +cmd
tizardsbriefcase.com.    21594    IN    A    46.32.230.161
tizardsbriefcase.com.    21594    IN    SOA    ns.tizardsbriefcase.com. root.stus.co. 1343036501 10800 3600 604800 10800
tizardsbriefcase.com.    21594    IN    TXT    "v=spf1 +a +mx -all"
tizardsbriefcase.com.    21594    IN    MX    10 mail.tizardsbriefcase.com.
tizardsbriefcase.com.    21594    IN    NS    ns.tizardsbriefcase.com.
[/code]

one step further towards tidy output though, you have to put the +nocmd flag before the domain name:

[code gutter=”false”]
dig +nocmd tizardsbriefcase.com any +noall +answer
tizardsbriefcase.com.    21542    IN    A    46.32.230.161
tizardsbriefcase.com.    21542    IN    SOA    ns.tizardsbriefcase.com. root.stus.co. 1343036501 10800 3600 604800 10800
tizardsbriefcase.com.    21542    IN    TXT    "v=spf1 +a +mx -all"
tizardsbriefcase.com.    21504    IN    MX    10 mail.tizardsbriefcase.com.
tizardsbriefcase.com.    21542    IN    NS    ns.tizardsbriefcase.com.
[/code]

tidier, however…

let’s go the long way around to get the a record ip, and do:

[code gutter=”false”]
dig +nocmd tizardsbriefcase.com a +noall +answer | cut -f5
[/code]

or do it the right way, using +short:

[code]dig tizardsbriefcase.com a +short[/code]

nicely formatted ttls

to get a tidy output to read the ttls, add +multiline:

[code gutter=”false”]
dig +nocmd tizardsbriefcase.com soa +noall +answer +multiline
tizardsbriefcase.com.    21414 IN SOA ns.tizardsbriefcase.com. root.stus.co. (
1343036501 ; serial
10800      ; refresh (3 hours)
3600       ; retry (1 hour)
604800     ; expire (1 week)
10800      ; minimum (3 hours)
)
[/code]

Leave a Reply

Your email address will not be published. Required fields are marked *