linux dig command and use examples

Linux dig – DNS lookup utility

➜  ~ dig www.linuxcommands.site

The linux dig command outputs 5 parts by default.

As shown below:

linux dig

1. The first part shows the version of the dig command and the parameters entered.

2. The second part shows some technical details returned by the service, such as: status. If the value of status is NOERROR, the query ends successfully.

3. The third part “QUESTION SECTION” shows the domain name to be queried.

4. The fourth part “ANSWER SECTION” is the result of the query.

5. The fifth part is some statistical information of this query, such as query time-consuming.

By default dig queries A records. Of course, dig also supports querying other DNS record types.

The correspondence between a domain name and an IP is called a “record“. Depending on the usage scenario, “records” can be divided into different types(type).

DNS common record type

TypeDescription
ADomain —-> ipv4
AAAADomain —-> ipv6
CNAMEDomain 1 —-> Domain 2
TXTUse a text record to enter any text string into a DNS entry with a length limit of 255.
NSThe domain name server records that if you need to give the subdomain to other DNS servers for resolution, you need to add an NS record.

Query records of type CNAME

➜  ~ dig www.qiyi.com CNAME

Specify the query on the DNS server

➜  ~ dig @8.8.8.8 www.qiyi.com

If you do not specify a DNS server, dig will use the address in /etc/resolv.conf as the DNS server in turn:

➜  ~ dig www.qiyi.com

Other DNS tools

1. host

host is a simple utility for performing DNS lookups.

➜  ~ host www.linuxcommands.site

The host command can also be used for reverse lookups, that is, querying a domain name from an IP address, equivalent to dig -x .

2. whois

The whois command is used to check the registration of a domain name.

➜  ~ whois www.linuxcommands.site

3. nslookup

The nslookup command is used to interactively query domain name records.

More about Linux commands: Linux Commands Tutorial

Add a Comment

Your email address will not be published. Required fields are marked *