How to Check Domain Availability via Command Line Using Whois and Dig
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
- 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.
- 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
sleepcommands. - 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
whoisanddigutilities installed. - Run a preliminary Whois check to look for registration strings like "No match".
- Confirm DNS non-existence by checking for
NXDOMAINusing Dig. - Implement sleep timers in scripts to avoid registry rate-limiting.
- Cross-reference ambiguous results using an online utility.