InfoHeap
Tech
Navigation
  • Home
  • Tutorials
    • CSS tutorials & examples
    • CSS properties
    • Javascript cookbook
    • Linux/Unix Command Line
    • Mac
    • PHP
      • PHP functions online
      • PHP regex
    • WordPress
  • Online Tools
    • Text utilities
    • Online Lint Tools
search

Networking tutorials

  • DIG quick start tutorial
  • Dig - list all dns records
  • How to view wifi connection speed on Mac
  • Linux iptables - Nat port forwarding using PREROUTING
  • Linux iptables and ip6tables examples
  • Ngrep - quick start guide
  • Use nc to check if a remote port is reachable
  • Use nc to listen to tcp or udp port
  • Use nc to test HTTP url redirection
  • add more DNS servers to Wi-Fi interface on Mac
  • locally override website host to IP mapping
  • use nc to print headers from browser
 
  • Home
  • > Tutorials
  • > Networking

DIG quick start tutorial for DNS Lookup

By admin on Oct 22, 2015

Dig (Domain information groper) can be used to do DNS lookup on Linux, Mac or windows machine. It will connect a DNS server (default or specified on command line) and look up the IP address, etc. for the given domain. Here are some typical DNS commands using dig. We’ll use Mac for the purpose of this article but these commands should work on Linux and windows also.

Basic dig usage

Run dig with the desired domain as shown below:

$ dig www.infoheap.com
; <<>> DiG 9.8.3-P1 <<>> www.infoheap.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 7240
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;www.infoheap.com.		IN	A

;; ANSWER SECTION:
www.infoheap.com.	1742	IN	CNAME	infoheap.com.
infoheap.com.		322	IN	A	54.183.1.40

;; Query time: 135 msec
;; SERVER: 202.56.230.5#53(202.56.230.5)
;; WHEN: Thu Oct 22 21:22:57 2015
;; MSG SIZE  rcvd: 64

Look at the answer section for the outcome. Here we are seeing CNAME and A record entries along with TTL (time to live in seconds) values. Note that dig used the network interface's default DNS server here.

DNS lookup using specific DNS server

Specify DNS server using @ when using dig. Here is the dig command which uses Google's public DNS server 8.8.8.8

$ dig @8.8.8.8 www.infoheap.com
...
...
...
;; Query time: 109 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Fri Oct 23 00:57:00 2015
;; MSG SIZE  rcvd: 64

Note the presence of "SERVER: 8.8.8.8" in the response as we are using this DNS server for query.

Query mx record

To query mx records (record to specify mail server for the top level domain), you can use type mx as shown below:

$ dig -t mx infoheap.com

Query nameservers for the top level domain

To query nameservers (autorative nameservers for the domain), use the following command:

$ dig -t ns infoheap.com

Query txt records

To query txt records associated with a domain:

$ dig -t txt infoheap.com

Trace DNS delegation path

To trace DNS delegation path, use the following command:

$ dig +trace infoheap.com

Suggested posts:

  1. Embed youtube video with javascript on-click lazy loading approach
  2. How to find recursion stack growth direction using C code
  3. Python re search vs match
  4. document querySelector examples
  5. How to use exerciser monkey tool for android stress testing
  6. Git – how to undo last commit
  7. jQuery – find total number of DOM elements
  8. How to use phantomjs to create site/url snapshot thumbnail
Share this article: share on facebook share on linkedin tweet this submit to reddit
Posted in Tutorials | Tagged Linux, Networking, Tutorials
  • Browse content
  • Article Topics
  • Article archives
  • Contact Us
Popular Topics: Android Development | AngularJS | Apache | AWS and EC2 | Bash shell scripting | Chrome developer tools | Company results | CSS | CSS cookbook | CSS properties | CSS Pseudo Classes | CSS selectors | CSS3 | CSS3 flexbox | Devops | Git | HTML | HTML5 | Java | Javascript | Javascript cookbook | Javascript DOM | jQuery | Kubernetes | Linux | Linux/Unix Command Line | Mac | Mac Command Line | Mysql | Networking | Node.js | Online Tools | PHP | PHP cookbook | PHP Regex | Python | Python array | Python cookbook | SEO | Site Performance | SSH | Ubuntu Linux | Web Development | Webmaster | Wordpress | Wordpress customization | Wordpress How To | Wordpress Mysql Queries | InfoHeap Money

Copyright © 2025 InfoHeap.

Powered by WordPress