Linux Dig Command Tutorial With Examples

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/linux-dig-command-tutorial-examples/
PINTEREST
PINTEREST
INSTAGRAM

Dig stands for Domain Information Groper. Dig is used to interrogate DNS servers. It have a lot of features to interact and use DNS servers. In this tutorial we will look popular and useful dig command usages. Most of the system and network administrators uses dig to debug DNS related issues.

Help

Help

Help

Man

Man

Man

Syntax

OR

Syntax

Syntax

Get IP Address

Dig is mostly used without parameter to get IP address of provided DNS name. The default system provided DNS server will be used to DNS resolution.

Get IP Address

Get IP Address

Show Only IP Address Line

As we see previous example dig will provide a lot of supportive information. This information may be not needed.

Show Only IP Address Line

Show Only IP Address Line

Show Only IP Address

Another useful feature is only printing IP address. There will be no other information other than IPv4. For this operations +short parameter can be used.

Show Only IP Address

Show Only IP Address

Show Only IPv4

By default all IP address versions IPv4 and IPv6 will be printed. This can be unnecessary in some situations. Printed IP address version can be specified with -4 parameter.

LEARN MORE  Linux Avahi Daemon Tutorial With Examples

Show Only IPv4

Show Only IPv4

Show Only IPv6

As like previous example we can only show IPv6 address with the -6 parameter like below.

Query MX Records

Mail servers can be expressed in DNS servers with the MX records. MX stands for Mail Exchanger. MX records specified the Domain name related mail server IP address. This mail server accepts mail with smtp protocol from senders.

Query NS Records

There are root DNS servers in the internet world. But these servers do not provide all DNS records all domain names. They just shows the Name Server of the querryd domain name. Those are called Name Servers. Dig can be list Name Servers with NS

Query NS Records

Query NS Records

Query TXT Records

TXT is short for text. This records are used informal generally human readable information about domain name. Keep in mind that this can be some times security problem.

Query TXT Records

Query TXT Records

Query SOA Records

SOA records are named as authority records. SOA records provides information about primary name server, email of domain administrator, domain serial number and some timers related refreshing zone. SOA records can be listed with SOA parameter.

Query SOA Records

Query SOA Records

Query All DNS Records Types

All DNS server records can be listed with ANY parameter.

Query All DNS Records Types

Query All DNS Records Types

Reverse Look-up

One of the most useful feature of dig is reverse DNS lookup. Up to now we have resolved domain names to the IP addresses. Some times resolving IP addresses into domain names can be useful. This can be done with -x parameter.

LEARN MORE  Expect Scripting Tutorial With Examples

Reverse Look-up

Reverse Look-up

Set Specific DNS Server

While querying different type of DNS records by default system provided DNS server is used. This may not be useful in some situations or we may want to test different DNS server than default one. The @ sign will be used to specify specific DNS server.

Set Specific DNS Server

Set Specific DNS Server

Multiple DNS Look-up

Generally only single domain name is queried with dig. But there are some times we may want to query multiple domain names in a single command. This can be done like below.

Multiple DNS Look-up

Multiple DNS Look-up

Bulk DNS Look-up

If there are multiple domain names to query these domain names can be provided with a file. Our file name is domains.txt and its content is like below.

and the command

Bulk DNS Look-up

Bulk DNS Look-up

Trace DNS Path

As we know DNS system of internet works as hierarchical manner. When we use dig to resolve some domain name this query is handled by multiple DNS servers in a row. These DNS servers process can be traced with +trace parameter.

Trace DNS Path

Trace DNS Path

Set Default Dig Options

Default usage parameter of dig can be made permanent and provided by default without issuing them every time. .digrc is the file that holds the configuration.

Set Default Dig Options

Set Default Dig Options

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/linux-dig-command-tutorial-examples/
PINTEREST
PINTEREST
INSTAGRAM

You may also like...

Leave a Reply

Your email address will not be published.

Enjoy this blog? Please spread the word :)