How to Query DNS Records Using the nslookup Command in Linux

When you type a domain name (like digitash.com) into a web browser, your computer cannot physically connect to it. The internet operates exclusively on IP addresses (like 192.168.1.50). Your computer must secretly contact a Domain Name System (DNS) server to translate the human-readable text into a machine-readable IP address. If a website suddenly stops loading, you must determine whether the physical web server crashed, or if the DNS translation engine simply failed. To mathematically interrogate DNS servers and extract raw routing data, you must use the nslookup command.

How the nslookup Command Works

The nslookup (Name Server Lookup) command is a direct, low-level network diagnostic tool. It bypasses your web browser entirely, reaches out across the internet, explicitly queries a DNS server, and demands to see the exact architectural routing records for a specific domain.

To execute a basic query, simply type the command followed by the target domain:

nslookup google.com

The terminal will instantly output two distinct blocks of data. The first block identifies the specific DNS server that answered your question (usually your ISP’s local router or Google’s public 8.8.8.8 server). The second block contains the actual answer, displaying the exact IPv4 and IPv6 addresses mathematically bound to google.com.

Querying Specific DNS Record Types

A domain name is not just a single IP address. It contains a massive matrix of highly specific architectural records (e.g., A records for web traffic, MX records for email routing, TXT records for security verification). By default, nslookup only returns the A record.

If a company’s email system completely crashes, you must force nslookup to exclusively interrogate the MX (Mail Exchange) records to see where the emails are currently being routed. You can do this by using the -query flag:

nslookup -query=mx digitash.com

The DNS server will completely ignore the web traffic routing and output a highly specific list of the physical mail servers responsible for handling digitash.com emails.

Interrogating Foreign DNS Servers

When you update a DNS record (like moving your website to a new host), the changes take time to propagate across the globe. If your local DNS server is caching old data, nslookup will lie to you.

To bypass your local cache and force the command to interrogate a completely different DNS server located halfway across the planet (like Cloudflare’s 1.1.1.1), simply append the target server’s IP address to the absolute end of the command:

nslookup digitash.com 1.1.1.1

This allows you to verify exactly what routing data a foreign server is currently broadcasting, instantly diagnosing global propagation delays.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.