InfoHeap
Tech tutorials, tips, tools and more
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. Using JSLint on command line on Ubuntu linux – quick start guide
  2. How to locally override website domain (or hostname) to IP mapping
  3. haxe openfl on mac – quick start guide for mobile development
  4. redis cli quick start tutorial
  5. Gulp quick start tutorial
  6. LXC (Linux Containers) – quick start tutorial on Ubuntu
  7. node-sass quick start tutorial on Linux and Mac
  8. Linux yum quick tutorial
Share this article: share on facebook share on linkedin tweet this submit to reddit
Posted in Tutorials | Tagged Linux, Networking, Tutorials

Follow InfoHeap

facebook
twitter
googleplus
  • Browse site
  • Article Topics
  • Article archives
  • Recent Articles
  • Contact Us
  • Omoney
Popular Topics: AngularJS | Apache | AWS and EC2 | Bash shell scripting | Chrome developer tools | CSS | CSS cookbook | CSS properties | CSS Pseudo Classes | CSS selectors | CSS3 | CSS3 flexbox | Devops | Git | HTML | HTML5 | Java | Javascript | Javascript cookbook | Javascript DOM | jQuery | 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

Copyright © 2022 InfoHeap.

Powered by WordPress