Networking

Linux dig command

Query DNS records and inspect the response returned by a DNS server.

Availability: Common Linux commands; shell built-ins and external implementations may differ by distribution.中文

Syntax

dig [@SERVER] NAME [TYPE] [QUERY-OPTIONS]

Examples

Query IPv4 address records and print concise results.

dig example.com A +short

Request the reverse DNS name for an address.

dig -x 192.0.2.10

Parameters, options and clauses

Option / clauseDescription
@SERVERSend the query to a chosen DNS server.
A / AAAA / MX / NSQuery common record types.
+shortPrint a concise answer section.
+traceFollow delegation from the DNS root.
+noall +answerShow only answer records.
-x ADDRESSPerform a reverse lookup for an address.
Safety note

Review a command and its target before running it. Commands that alter files, services, accounts, disks, permissions or databases may be difficult to reverse. Test in a safe environment and keep backups.

Official reference ↗Back to directory