How to Check DNS Propagation Using CLI

  ·   3 min read

DNS propagation is a critical aspect of managing domain names and ensuring that changes to DNS records are reflected across the internet. When you update DNS records, it can take some time for these changes to propagate to all DNS servers worldwide. As a DevOps engineer, it’s essential to verify DNS propagation to ensure that your services are accessible and functioning correctly. In this article, we’ll explore how to check DNS propagation using command-line interface (CLI) tools, focusing on open-source solutions.

Understanding DNS Propagation

Before diving into the tools, it’s important to understand what DNS propagation is. When you update a DNS record, such as an A record or CNAME, the change is first made on the authoritative DNS server. However, DNS information is cached by various DNS servers around the world to improve lookup speeds and reduce load. This means that changes may not be immediately visible everywhere, as cached records need to expire before the new information is fetched.

Tools for Checking DNS Propagation

Several CLI tools can help you check DNS propagation. The most commonly used ones are dig and nslookup. Both tools are available on most Unix-like operating systems, including Linux and macOS, and can be installed on Windows.

Using dig

dig (Domain Information Groper) is a powerful and flexible tool for querying DNS servers. It provides detailed information about DNS records and is widely used by network administrators and DevOps engineers.

To check DNS propagation using dig, follow these steps:

  1. Open your terminal.

  2. Use the following command to query a specific DNS server:

    dig @<dns-server> <domain> <record-type>
    

    Replace <dns-server> with the IP address of the DNS server you want to query, <domain> with your domain name, and <record-type> with the type of DNS record you want to check (e.g., A, CNAME, MX).

  3. For example, to check the A record for example.com using Google’s public DNS server (8.8.8.8), you would run:

    dig @8.8.8.8 example.com A
    
  4. Review the output to see if the DNS record has propagated to the queried server.

Using nslookup

nslookup is another command-line tool for querying DNS servers. It is simpler than dig but still effective for basic DNS queries.

To use nslookup for checking DNS propagation:

  1. Open your terminal.

  2. Use the following command:

    nslookup <domain> <dns-server>
    

    Replace <domain> with your domain name and <dns-server> with the IP address of the DNS server you want to query.

  3. For example, to check the A record for example.com using Cloudflare’s public DNS server (1.1.1.1), you would run:

    nslookup example.com 1.1.1.1
    
  4. Examine the output to determine if the DNS record has propagated.

Conclusion

Checking DNS propagation is a crucial task for DevOps engineers to ensure that DNS changes are correctly reflected across the internet. By using CLI tools like dig and nslookup, you can efficiently verify DNS propagation and troubleshoot any issues that may arise. These open-source tools are powerful, flexible, and widely available, making them essential components of any DevOps toolkit.

References