How can I find the WHOIS server for any TLD?

Solution 1:

There are several well-known ways of locating whois servers for TLDs, the IANA database is probably the closest to what the question asks for, however there are other sources that may be more useful in practice.

From IANA (access via whois and http)

Browse http://www.iana.org/domains/root/db or search the whois database at whois.iana.org for the TLD. Each entry has a field specifying the whois server.

Example:

$ whois -h whois.iana.org com
[Querying whois.iana.org]
[whois.iana.org]
% IANA WHOIS server
% for more information on IANA, visit http://www.iana.org
% This query returned 1 object

domain:       COM

organisation: VeriSign Global Registry Services
address:      12061 Bluemont Way
address:      Reston Virginia 20190
address:      United States

contact:      administrative
name:         Registry Customer Service
organisation: VeriSign Global Registry Services
address:      12061 Bluemont Way
address:      Reston Virginia 20190
address:      United States
phone:        +1 703 925-6999
fax-no:       +1 703 948 3978
e-mail:       [email protected]

contact:      technical
name:         Registry Customer Service
organisation: VeriSign Global Registry Services
address:      12061 Bluemont Way
address:      Reston Virginia 20190
address:      United States
phone:        +1 703 925-6999
fax-no:       +1 703 948 3978
e-mail:       [email protected]

nserver:      A.GTLD-SERVERS.NET 192.5.6.30 2001:503:a83e:0:0:0:2:30
nserver:      B.GTLD-SERVERS.NET 192.33.14.30 2001:503:231d:0:0:0:2:30
nserver:      C.GTLD-SERVERS.NET 192.26.92.30
nserver:      D.GTLD-SERVERS.NET 192.31.80.30
nserver:      E.GTLD-SERVERS.NET 192.12.94.30
nserver:      F.GTLD-SERVERS.NET 192.35.51.30
nserver:      G.GTLD-SERVERS.NET 192.42.93.30
nserver:      H.GTLD-SERVERS.NET 192.54.112.30
nserver:      I.GTLD-SERVERS.NET 192.43.172.30
nserver:      J.GTLD-SERVERS.NET 192.48.79.30
nserver:      K.GTLD-SERVERS.NET 192.52.178.30
nserver:      L.GTLD-SERVERS.NET 192.41.162.30
nserver:      M.GTLD-SERVERS.NET 192.55.83.30
ds-rdata:     30909 8 2 E2D3C916F6DEEAC73294E8268FB5885044A833FC5459588F4A9184CFC41A5766

whois:        whois.verisign-grs.com

status:       ACTIVE
remarks:      Registration information: http://www.verisign-grs.com

created:      1985-01-01
changed:      2012-02-15
source:       IANA

$

From whois-servers.net (access via DNS)

The name tld.whois-servers.net is a CNAME to the appropriate whois-server. Somewhat unclear who actually maintains this but it seems pretty popular as it's very easy to use this with pretty much any whois client (and some clients default to using this service).

Example:

$ dig com.whois-servers.net +noall +answer

; <<>> DiG 9.9.4-P2-RedHat-9.9.4-15.P2.fc20 <<>> com.whois-servers.net +noall +answer
;; global options: +cmd
com.whois-servers.net.  600     IN      CNAME   whois.verisign-grs.com.
whois.verisign-grs.com. 5       IN      A       199.7.55.74
$

From the registry itself (access via DNS)

Many registries publish the address of their whois server in DNS directly in the relevant zone as a _nicname._tcp SRV record.

Example:

$ dig _nicname._tcp.us SRV +noall +answer

; <<>> DiG 9.9.4-P2-RedHat-9.9.4-15.P2.fc20 <<>> _nicname._tcp.us SRV +noall +answer
;; global options: +cmd
_nicname._tcp.us.       518344  IN      SRV     0 0 43 whois.nic.us.
$

Solution 2:

I regularly compile a list from IANA and PSL into a XML file including whois server, registrar, second level domains and if possible a regular expression for availabilty: https://github.com/whois-server-list/whois-server-list


Solution 3:

I've been playing around with WHOIS lately and I've found that some of the publicly-available whois packages [namely CentOS's jwhois] seem to rely on pre-packaged lists of TLD WHOIS servers. While this is going to be fine for the majority of TLDs it's a problem for the explosion of esoteric gTLDs like .horse.

The 100% reliable method is to look up the TLD at IANA's WHOIS server, whois.iana.org, parse out the whois: entry, and then query that server for the domain's information. Eg:

foo@bar:~ $ echo -e "horse\r\n" | nc -i 1 whois.iana.org 43
% IANA WHOIS server
% for more information on IANA, visit http://www.iana.org
% This query returned 1 object

domain:       HORSE

[snip]

whois:        whois-dub.mm-registry.com

[snip]

Connection closed by foreign host.

And then:

foo@bar:~ $ echo -e "dord.horse\r\n" | nc -i 1 whois-dub.mm-registry.com 43
Domain Name: dord.horse
Domain ID: 1742946-MMd1
WHOIS Server: whois-dub.mm-registry.com
[snip]

If you're using this method you should be polite and cache responses from the IANA server for at least 48 hours, if not longer, as they will rarely change and IANA's servers tend to be under massive load.


Solution 4:

I maintain the list of WHOIS servers for my Ruby WHOIS library at https://github.com/weppos/whois/blob/master/data/tld.json

It contains the list of all existing servers.

It doesn't contain the response when the domain is available because the Ruby library performs parsing at a different level. Also, keep in mind not all registries uses string messages to communicate the unavailability of a domain.


Solution 5:

you can use this script to get whois servers from IANA. chreated by noys. output in JSON list of zones and whois servers.

<style>
body {
    font: normal 10px verdana, sans-serif;
    color: #333;
}
</style>

<?
$zones = array('ac','am','asia','at','be','biz','biz.ua','biz.ua','br.com','bz','cc','ch','co','co.am','co.in','co.ua','co.ua','om','com.am','com.kz','com.ua','cx','cz','de.com','eu','eu.com','firm.in','fm','gen.in','im','in','ind.in','info','io','kiev.ua','kz','la','lc','li','lt','lu','md','me','mn','mobi','ms','mx','name','net','net.am','net.in','org','org.am','org.in','org.kz','ph','pl','pp.ua','pro','pw','pw','ru','ru.com','so','su','su','su','tel','tv','tw','us','uy.com','vc','ws','xxx','za.cm','xn--p1ai');

$count = count($zones);

echo '<h1>Whois tool</h1>';

echo '<pre>
{
';

for($i=0;$i<$count;$i++) {
    $root_server = 'whois.iana.org';
    $zone = $zones[$i];
    $domain = 'nuceti75.'.$zones[$i];
    //echo "<h2>$domain - $current_domain</h2>";
    $fp = fsockopen($root_server, 43);
    if (!$fp) echo "Connection error: $root_server \r\n";
    else { 
        fputs($fp, $zone."\r\n");
        while (!feof($fp)) {
            $root_answer .= fgets($fp, 128);
        }
        preg_match("~whois:\s(.+)~i", $root_answer, $result);
        $current_server = trim($result[1]);
        fclose($fp);
    } 

    //echo "<pre>$root_answer</pre>";
    //echo "<b>Whois server for this TLD:</b> $current_server";

    $fh = fsockopen($current_server, 43);
    if (!$fh) echo "Connection error: $current_server ($zone) \r\n";
    else { 
        fputs($fh, $domain."\r\n");
        while (!feof($fh)) {
            $current_answer .= fgets($fh, 128);
        }
        fclose($fh);
    }

    //echo "<pre>$current_answer</pre>";

    echo "\"$zone\": \"$current_server\",\r\n";

    unset($root_answer);
    unset($current_answer);
    unset($result);

}

echo '
}
</pre>';

?>