Useful examples of dig command
This recipe is about the dig command in Unix and some useful examples, which you can find interesting when scripting or when need to check your address from inside the machine that you are accessing by the private network.
dig is an acronym for Domain Information Groper and is a command-line utility that performs DNS lookup by querying name servers and displaying the result to you. It is part of the dnsutils package in Debian, make sure you have that installed.
The syntax is:
|
|
Some examples:
To get you ip adress, using the server resolver1.opendns.com:
|
|
Get the address for bigg.blog
|
|
Command to get a list of the mailservers for bigg.blog
|
|
The following command is to get a list of authoritative DNS servers for bigg.blog
|
|
To get a list of all the above (MX and NS) at once
|
|
Trace the path taken to resolve the name
|
|
Reverse lookup
|
|
Query names from a file
|
|
To customise permanently the output, you need to create a file ~/.digrc like
|
|
Now, when dig is executed it will show only answer section will output.
Hope it helps you
Have a great day
G