Getting DNS information with dig

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 - http://peter.upfold.org.uk/

Peter Upfold is a technology enthusiast from the UK. Peter’s interest in Linux stems back to 2003, when curiosity got the better of him and he began using SUSE 9.0. Now he runs Linux Mint 9 on the desktop, runs a CentOS-based web server from home for his personal website and dabbles in all sorts of technology things across the Windows, Mac and open source worlds.

Home » Articles »

Discussion: Getting DNS information with dig

Home » Articles » Getting DNS information with dig