Using Dig command Print

  • 0

Introduction: The dig command is a tool used to query DNS (Domain Name System) information. It allows you to retrieve details about domain names, IP addresses, and other DNS records. This tutorial will introduce you to the basic usage of the dig command.

Step 1: Opening a Command-Line Interface Open a command-line interface on your computer. The method may vary depending on your operating system:

  • On Windows, open the Command Prompt or PowerShell.
  • On macOS or Linux, open the Terminal.

Step 2: Basic Query Let's start with a basic query to retrieve the IP address associated with a domain name. Type the following command:


Replace "" with the domain name you want to query. Press Enter to execute the command.

Step 3: Understanding the Output The dig command will display the output, which contains various sections providing DNS information. Look for the "ANSWER SECTION" in the output. It will show the IP address associated with the domain name you queried.

Step 4: Querying Specific DNS Record Types You can also query specific DNS record types. For example, to retrieve the mail servers (MX records) for a domain, use the following command:

dig MX

Replace "" with the domain name you want to query. This will display the mail servers associated with the domain.

Step 5: Querying a Specific DNS Server By default, dig uses your system's configured DNS servers. However, you can specify a specific DNS server to query. For example, to query Google's public DNS server, use the following command:

dig @

Replace "" with the IP address of the DNS server you want to query. This will send the query directly to that DNS server.

You can also use the same DNS server and the domain to ask which record type you want to check for example is the MX record. 

dig @ MX

Was this answer helpful?

« Back