我如何find任何TLD的WHOIS服务器?

我正在寻找一个可靠和最新的Whois脚本中使用的WHOIS服务器列表。
由于列表频繁变化,如果有一个我可以参考的资源,而不是经常更新脚本,那就好了。

我在https://github.com/weppos/whois/blob/master/data/tld.json维护我的Ruby WHOIS库的WHOIS服务器列表

它包含所有现有服务器的列表。

当域可用时,它不包含响应,因为Ruby库在不同级别执行parsing。 另外请记住,并非所有注册pipe理机构都使用string消息来传递域的不可用性。

有几种众所周知的为TLD定位whois服务器的方法,IANA数据库可能最接近问题所要求的,但是还有其他的来源在实践中可能更有用。

从IANA(通过whois和http访问)

浏览http://www.iana.org/domains/root/db或在whois.iana.orgsearchwhois.iana.org的whois数据库以获得TLD。 每个条目都有一个指定whois服务器的字段。

例:

 $ 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 $ 

从whois-servers.net(通过DNS访问)

名称tld.whois-servers.net是适当whois-server的CNAME 。 有些不清楚的是谁真的维护这个,但它似乎非常stream行,因为它非常容易与几乎所有的whois客户端(和一些客户端默认使用此服务)一起使用。

例:

 $ 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 $ 

从registry本身(通过DNS访问)

许多注册pipe理机构将DNS中whois服务器的地址作为_nicname._tcp SRVlogging直接发布到相关区域中。

例:

 $ 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. $ 

我定期从IANA和PSL编制一个列表,将其列入一个XML文件,包括whois服务器,注册服务商,二级域名以及可能的正式expression式: https : //github.com/whois-server-list/whois-server-list

你不应该需要这些列表。 whois(1)很聪明,可以为你解决这个问题:

对于手册页:

  By default whois constructs the name of a whois server to use from the top-level domain (TLD) of the supplied (single) argu- ment, and appending ".whois-servers.net". This effectively allows a suitable whois server to be selected automatically for a large number of TLDs. 

Whois通常很可靠。 我永远不记得看到它失败的域名。

您可以使用此脚本从IANA获取whois服务器。 被noys榨干。 输出在区域和whois服务器的JSON列表中。

 <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>'; ?> 

最近我一直在玩WHOIS,我发现一些公开的whois包(即CentOS的jwhois)似乎依赖于TLD WHOIS服务器的预先打包列表。 虽然这对大多数顶级域名(TLD)来说都是很好的,但对于象.horse这样的深奥通用顶级域名(gTLD)的爆炸来说,这是一个问题。

100%可靠的方法是在IANA的WHOIS服务器whois.iana.org上查找TLD,parsingwhois:条目,然后向该服务器查询该域的信息。 例如:

 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. 

接着:

 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] 

如果您使用这种方法,则应该礼貌并caching来自IANA服务器的响应至less48小时(如果不是更长),因为它们很less会发生变化,IANA的服务器往往会承受巨大的负载。