Getting DNS information with dig

  • April 28, 2007
  • Avatar for peter
    Peter
    Upfold

There exists a neat little tool in Unix command line toolbox called dig. The dig tool is designed to allow you to pull up DNS information and can be useful if you're having network problems, or messing around with your DNS.

You invoke dig by running it from the terminal. You need to give it a domain name for it to look up.

$ dig fosswire.com

This throws up some pretty geeky DNS information. There are a plethora of options available, so I won't go over them all here. Remember, the man page can help there.

I will go over a couple of options here:d

If you pass the +short option to dig, it will give you a really short and sweet answer - just the IP address.

$ dig fosswire.com +short
208.113.149.33

If you want to do a reverse lookup - that is to say, get a domain name from an IP address, use the -x switch:

$ dig -x 208.113.149.33

If you're interested in more dig options and really advanced stuff, there is a really neat howto on the dig tool over at madboa.com.

If you don't quite need the flexibility and power of dig and you just want to see what a particular hostname is resolving to, use nslookup:

$ nslookup fosswire.com

Avatar for peter Peter Upfold

Home » Articles »