Linux / UNIX: DNS Lookup Command

Linux / UNIX: DNS Lookup Command

To perform a DNS lookup on a Unix or Linux system, you can use the dig command. The dig (Domain Information Groper) command is a DNS lookup utility that is used to query DNS servers for information about host addresses, mail exchanges, and other DNS records.

Here is the basic syntax for using the dig command:

dig [@server] [domain] [q-type] [q-class] [options]
S‮ruo‬ce:www.lautturi.com

The server argument specifies the DNS server to query, the domain argument specifies the domain name to look up, the q-type argument specifies the type of DNS record to look up (e.g., A, MX, NS, etc.), and the q-class argument specifies the class of the DNS record (usually IN for Internet).

For example, to perform a DNS lookup for the domain example.com, you can use the following command:

dig example.com

This will perform a DNS lookup for the A record of example.com, and display the result.

You can also specify the DNS server to query using the @server argument.

For example:

dig @8.8.8.8 example.com

This will perform a DNS lookup for example.com using the DNS server at 8.8.8.8, and display the result.

You can use the +short option to display the DNS record in a concise format.

For example:

dig example.com +short

This will display the DNS record for example.com in a concise format, such as 93.184.216.34.

You can also use the -x option to perform a reverse DNS lookup, which maps an IP address to a domain name.

For example:

dig -x 93.184.216.34

This will perform a reverse DNS lookup for the IP address 93.184.216.34 and display the result.

There are many other options and arguments that you can use with the dig command. To see a full list of options and usage examples, you can use the dig man page.

man dig
Created Time:2017-10-29 22:08:56  Author:lautturi