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

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