Nice WHOIS – Clean WHOIS Bash Script with Smart Fallback

Nice WHOIS - Clean WHOIS Bash Script with Smart Fallback

Nice WHOIS is a Bash script that performs clean, color-formatted WHOIS lookups. It parses and deduplicates raw whois output, strips boilerplate legal notices, and falls back to RDAP or web lookups when standard whois is unavailable. It also resolves the correct whois server via IANA when the local client fails, making TLDs like .org work out of the box.

Preview

Features

  • Clean, color-formatted output.
  • Deduplication of repeated whois key-value pairs while preserving multi-value fields (for example nameservers and statuses).
  • Boilerplate/legal text filtering with configurable skip patterns (SKIP_BLOCKS, SKIP_KEYS).
  • Automatic IANA whois server discovery and retry (whois.iana.org), which lets lookups succeed for TLDs that the local whois client does not handle correctly by default.
  • RDAP fallback when whois fails or is blocked, with per-TLD RDAP overrides (RDAP_SERVERS) plus rdap.org fallback.
  • Web fallback for TLDs with no public whois/RDAP (WEB_WHOIS).
  • Nameserver handle expansion (resolves handle-style nameserver IDs to hostnames).
  • Input validation and timeout-based lookups to avoid hanging queries (WHOIS_TIMEOUT, default 3 seconds).

Lookup Flow

The script resolves domain information using a multi-step fallback strategy:

  1. Validate input – require exactly one domain argument and validate domain format.
  2. Web-only exit – if TLD is listed in WEB_WHOIS, print the registry web lookup URL and stop.
  3. Standard whois attempt – run whois <domain.tld> with timeout.
  4. IANA-assisted whois retry – if failed/blocked, query whois.iana.org for authoritative server and retry with whois -h.
  5. RDAP fallback – if whois still failed/blocked, query RDAP_SERVERS[tld] override when present, otherwise https://rdap.org/domain/<domain>.
  6. RDAP parsing path – print domain, statuses, events, DNSSEC, registrar details, and nameservers from JSON.
  7. WHOIS parsing path – if whois succeeded, detect “not found”, then parse/clean output, filter boilerplate, deduplicate repeated KVs, and print formatted result.
  8. Nameserver handle resolution – for handle-style nameserver values from whois output, perform follow-up lookups and print resolved hostnames.

Requirements

  • whois – standard whois client
  • jq – JSON processor (required for RDAP fallback)
  • curl – HTTP client (required for RDAP fallback)
# Debian/Ubuntu
sudo apt install whois jq curl

# RHEL/Fedora
sudo dnf install whois jq curl

# Arch
sudo pacman -S whois jq curl

Usage

  1. Make the script executable:
chmod +x nw.sh
  1. Run the script:
./nw.sh example.com

Adding Nice WHOIS to PATH

To run nw from anywhere without specifying the full path:

  1. Option A – Symlink to a directory already in PATH:
sudo ln -s /full/path/to/nw.sh /usr/local/bin/nw
  1. Option B – Add the script’s directory to PATH:

Add the following to your shell profile (~/.bashrc or ~/.zshrc):

export PATH="$PATH:/full/path/to/nw-directory"

Then either restart your terminal or reload:

source ~/.bashrc
  1. Option C – Shell alias:

Add to ~/.bashrc or ~/.zshrc:

alias nw='/full/path/to/nw.sh'

After any of these, you can run:

nw example.com

Configuration

WHOIS_TIMEOUT – Timeout in seconds for whois queries (default 3).

WEB_WHOIS – TLDs with no public whois or RDAP. The script will display the web URL and exit immediately.

declare -A WEB_WHOIS=(
    ["es"]="https://www.dominios.es/en"
)

RDAP_SERVERS – TLDs that need a specific RDAP endpoint (when rdap.org does not cover them).

declare -A RDAP_SERVERS=(
    ["ch"]="https://rdap.nic.ch"
    ["li"]="https://rdap.nic.ch"
    ["me"]="https://rdap.identitydigital.services/rdap"
)

SKIP_BLOCKS – case-insensitive substring patterns used to skip noisy whois blocks.

SKIP_KEYS – case-insensitive key-prefix patterns used to skip noisy key-value lines (without matching user data values).

Get the Script

nicewhois

https://github.com/PaulSorensen/nicewhois

Clean, color-formatted WHOIS lookup tool with IANA retry, RDAP and web fallback.

Last Updated: February 26, 2026

Categories: Scripts