Linux dig – DNS lookup utility
➜ ~ dig www.linuxcommands.site
The linux dig command outputs 5 parts by default.
As shown below:
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
|A||Domain —-> ipv4|
|AAAA||Domain —-> ipv6|
|CNAME||Domain 1 —-> Domain 2|
|TXT||Use a text record to enter any text string into a DNS entry with a length limit of 255.|
|NS||The 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 @18.104.22.168 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
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 .
The whois command is used to check the registration of a domain name.
➜ ~ whois www.linuxcommands.site
The nslookup command is used to interactively query domain name records.
More about Linux commands: Linux Commands Tutorial