1597271100
Dig (Domain Information Groper) is a powerful command-line tool for querying DNS name servers.
The dig
command, allows you to query information about various DNS records, including host addresses, mail exchanges, and name servers. It is the most commonly used tool among system administrators for troubleshooting DNS problems because of its flexibility and ease of use.
This tutorial explains how to use the dig
utility through practical examples and detailed explanations of the most common dig
options.
dig
To check if the dig
command is available on your system type:
dig -v
The output should look something like this:
DiG 9.11.3-1ubuntu1.1-Ubuntu
If dig
is not present on your system, the command above will print “dig: command not found”. The dig
tool can be installed using the distro’s package manager.
dig
on Ubuntu and Debiansudo apt update && sudo apt install dnsutils
dig
on CentOS and Fedorasudo yum install bind-utils
dig
on Arch Linuxsudo pacman -S bind-tools
dig
OutputIn its simplest form, when used to query a single host (domain) without any additional options, the dig
command is pretty verbose.
In the following example, we’re performing on the linux.org
domain:
dig linux.org
The output should look something like this:
Let’s go section by section and explain the output of the dig
command:
dig
version, and the queried domain name. The second line shows the global options (by default, only cmd).; <<>> DiG 9.13.3 <<>> linux.org
;; global options: +cmd
+nocmd
option. This option must be the very first one after the dig
command.dig
) and the status of the action. In this example, the status is NOERROR
, which means that the requested authority served the query without any issue.;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 37159
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 2, ADDITIONAL: 5
+nocomments
option, which also disables some other section’s headers.dig
utility. You can read more about the Extension mechanisms for DNS (EDNS) here .;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
+noedns
option.dig
shows the query (question). By default, dig
requests the A record.;; QUESTION SECTION:
;linux.org. IN A
+noquestion
option.dig
will request the A record. Here, we can see that the domain linux.org
points to the 104.18.59.123
IP address.;; ANSWER SECTION:
linux.org. 300 IN A 104.18.59.123
linux.org. 300 IN A 104.18.58.123
+noanswer
option.;; AUTHORITY SECTION:
linux.org. 86379 IN NS lia.ns.cloudflare.com.
linux.org. 86379 IN NS mark.ns.cloudflare.com.
+noauthority
option.;; ADDITIONAL SECTION:
lia.ns.cloudflare.com. 84354 IN A 173.245.58.185
lia.ns.cloudflare.com. 170762 IN AAAA 2400:cb00:2049:1::adf5:3ab9
mark.ns.cloudflare.com. 170734 IN A 173.245.59.130
mark.ns.cloudflare.com. 170734 IN AAAA 2400:cb00:2049:1::adf5:3b82
+noadditional
option disables the additional section of a reply.dig
output includes statistics about the query.;; Query time: 58 msec
;; SERVER: 192.168.1.1#53(192.168.1.1)
;; WHEN: Fri Oct 12 11:46:46 CEST 2018
;; MSG SIZE rcvd: 212
+nostats
option.#linux
1625631509
Dig Command Line Options and Examples
Here is the frequently used command line options and example’s of dig command.
1. Basic Dig Command
A basic dig command accept domain name as command line parameter and prints Address record.
2. Query With Specific DNS Server
The default dig command queries to dns server configured on your system. For example, the Linux systems keep default DNS entry in /etc/resolv.conf.
3. Print Short Answer
Use +short command line option to print result in short form. This is basically useful with the shell scripting and other automation tasks.
4. Print Detailed but Specific Result
Use +noall with +answer to print detailed information but specific. This will print only answer section including few more details as a result.
#linux commands #command #dig #dig command #useful examples #linux
1625625674
mv Command Examples
Below is the basic mv command examples on Linux terminal.
#linux commands #command #mv #useful example #mv command #linux
1591066173
This tutorial will be showing you how to protect your DNS privacy on Linux Mint with DNS over TLS. We will use a tool called stubby, but first, let me tell you why DNS is not secure.
#linux mint #dns over tls #linux #linux mint desktop #linux mint server #stubby
1625562321
date Command Examples
Show date time in UTC/GMT
View past dates on specific days
View future dates
View date in other timezone
Print date in specific format
View file modification time
#linux commands #command #date #linux
1625539062
…
#linux commands #terminal #funny commands #linux