Linux dig command

The dig command is a powerful tool used in Linux and Unix-like operating systems to perform DNS (Domain Name System) queries. It allows you to retrieve various types of information related to DNS, such as IP addresses, MX (mail exchange) records, CNAME (canonical name) records, and more.

The basic syntax of the dig command is as follows:

dig [options] [domain]

Here, [options] refers to the various flags and parameters you can use with the command, and [domain] represents the domain name or hostname you want to query.

Some commonly used options with dig include:

  • A: Retrieves the IPv4 address associated with the domain.
  • AAAA: Retrieves the IPv6 address associated with the domain.
  • MX: Retrieves the mail exchange records for the domain.
  • CNAME: Retrieves the canonical name (alias) for the domain.
  • NS: Retrieves the name server records for the domain.
  • TXT: Retrieves the text records associated with the domain.

To use the dig command, open a terminal and enter the command followed by the desired options and the domain name. Here are a few examples:

  1. Retrieve the IPv4 address of a domain:
dig A example.com
  1. Retrieve the IPv6 address of a domain:
dig AAAA example.com
  1. Retrieve the mail exchange records of a domain:
dig MX example.com
  1. Retrieve the canonical name of a domain:
dig CNAME example.com

These are just a few examples, and there are many more options and variations you can use with the dig command. To explore additional options and information, you can refer to the dig command’s manual page by typing man dig in the terminal.