XiaTools

How to Check Domain Availability via Command Line Using Whois and Dig

Updated 10 Oct 2026

Performing a command line domain availability check using Whois and Dig gives you instant, raw query data without the clutter of commercial registrar websites. By bypassing browser interfaces, you can query registry databases directly, inspect authoritative nameservers, and even script bulk lookups for infrastructure planning. To speed up day-to-day administrative checks when you are away from the terminal, you can also use the free Domain Availability Checker on XiaTools for instant browser-based lookups.

Understanding the Core Tools: Whois vs. Dig

When verifying whether a domain name is registered, you are interacting with two distinct layers of the Domain Name System and registry architecture. Understanding what each tool does ensures you interpret the output correctly.

Whois Protocol

Whois is a query and response protocol running on TCP port 43 that queries registry databases to find ownership, registration dates, registrar details, and authoritative nameserver records. When you run a Whois command, your local client connects directly to the Top-Level Domain (TLD) registry's designated Whois server.

Dig Utility

Dig (Domain Information Groper) is a flexible tool for interrogating DNS nameservers. It performs DNS lookups and displays answers from the queried nameservers. While Whois tells you if a domain is registered in a database, Dig tells you how the live DNS infrastructure is currently resolving the domain name.

Feature Whois Dig
Primary Purpose Ownership and registration status DNS record resolution and nameservers
Port Used TCP 43 UDP/TCP 53
Target Database TLD Registry / Registrar Database Authoritative and Recursive Nameservers
Availability Indicator "No match" or "Not found" strings NXDOMAIN (Non-Existent Domain) response

Step-by-Step Domain Availability Check Using Whois

Most Unix-like operating systems (Linux, macOS) include a native whois client. If you are on Windows, you can use PowerShell or download the official Sysinternals Whois utility.

Basic Whois Query

Open your terminal and run the following command to query example.com:

whois example.com

Sample output from a registered domain:

Domain Name: EXAMPLE.COM
Registry Domain ID: 2336799_DOMAIN_COM-VRSN
Registrar WHOIS Server: whois.iana.org
Registrar URL: http://reseller.iana.org
Updated Date: 2023-08-14T07:01:35Z
Creation Date: 1995-08-14T04:00:00Z
Registry Expiry Date: 2024-08-13T04:00:00Z
Registrar: Reserved Domain
Domain Status: clientDeleteProhibited https://icann.org/epp#clientDeleteProhibited

If the domain is available, the Whois server will typically return a string such as No match for "AVAILABLEDOMAIN12345.COM" or Not found.

Querying Specific TLD Registrars

Sometimes your local client fails to route the query to the correct TLD registry. You can specify the exact Whois server using the -h flag:

whois -h whois.verisign-grs.com example.com

Step-by-Step Domain Availability Check Using Dig

Using Dig for availability relies on checking the existence of Start of Authority (SOA) or address (A) records. If a domain has no active DNS records, it often returns an NXDOMAIN status.

Querying DNS Records with Dig

Run the following command in your terminal:

dig example.com SOA

Sample output for an active domain:

; <<>> DiG 9.16.1-Ubuntu <<>> example.com SOA
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, answer: 1, authority: 0, additional: 1

;; QUESTION SECTION:
;example.com.		In	SOAN

;; ANSWER SECTION:
example.com.st	3600	IN	SOA	ns.icann.org. noc.dns.icann.org. 2023456789 7200 3600 120800 3600

If the domain is completely unregistered and unconfigured, the status line will read status: NXDOMAIN and the answer section will be empty.

Checking Nameserver Delegation

To see which nameservers handle a domain, query the NS records:

dig example.com NS +short

Automating Availability Checks via PowerShell and Bash

When launching a new project, you often need to check dozens of potential names at once. You can write simple shell scripts to automate this.

Bash Loop for Bulk Checking

Create a text file named domains.txt containing one domain per line (e.g., example.com, example.net), then run:

while read domain; do
  result=$(whois "$domain" | grep -iE "No match|Not found|No Data Found")
  if [ -n "$result" ]; then
    echo "[AVAILABLE] $domain"
  else
    echo "[TAKEN] $domain"
  fi
done < domains.txt

PowerShell Script for Windows Users

Save the following script as check-domains.ps1:

$domains = @("example.com", "example.net", "example.org")
foreach ($domain in $domains) {
    $lookup = nslookup -type=SOA $domain 2>&1
    if ($lookup -match "NXDOMAIN") {
        Write-Host "Domain $domain appears available." -ForegroundColor Green
    } else {
        Write-Host "Domain $domain is registered." -ForegroundColor Red
    }
}

Common Mistakes and How to Fix Them

  1. Relying Solely on DNS for Availability: A domain can be registered at a registrar without having active DNS records configured. Always verify with Whois in addition to Dig to confirm true ownership status.
  2. Hitting Rate Limits: Public Whois servers enforce strict rate limits. If you query too many domains rapidly from a single IP address, your requests will be dropped or temporarily blocked. Space out your automated queries with sleep commands.
  3. Incorrect TLD Routing: Generic Top-Level Domains (gTLDs) and country-code Top-Level Domains (ccTLDs) require specific Whois servers. If your default client outputs garbage data, specify the registry server manually.

Domain Availability Check Checklist

  • Verify your local terminal has native whois and dig utilities installed.
  • Run a preliminary Whois check to look for registration strings like "No match".
  • Confirm DNS non-existence by checking for NXDOMAIN using Dig.
  • Implement sleep timers in scripts to avoid registry rate-limiting.
  • Cross-reference ambiguous results using an online utility.

Frequently asked questions

Why does Whois return different outputs for different domains?

Different Top-Level Domain registries operate their own Whois servers with unique database schemas and output formats. While generic strings like "No match" are common, ccTLD registries often format expiration dates and status flags differently.

Can I check domain availability behind a corporate firewall?

Corporate firewalls frequently block outbound TCP port 43, which is required for Whois queries. If your queries time out, check your network policies or use a web-based tool instead.

Is an NXDOMAIN response from Dig proof that a domain is available?

Not entirely. An NXDOMAIN response simply means no DNS records exist on the queried nameserver. The domain might still be actively registered at a registrar without any active DNS zone file configured.

How can I prevent my IP address from getting blocked by Whois servers?

Registry operators track query frequency to prevent scraping and abuse. To avoid temporary IP bans during bulk checks, introduce a delay of several seconds between individual queries in your automation scripts.

Are command line checks more accurate than registrar search bars?

Yes, command line tools query registry databases directly without intermediary caching layers. Registrar websites sometimes promote premium alternatives or suggest variations instead of giving you the raw registry status.

Related articles

Free tools