当前位置: 首页 > backend >正文

whois为什么有时会返回两个不同的域名状态

前阵子发现一直想注册但被别人注册了的一个域名快要过期了,就想着写个脚本跑在电脑上,每分钟检查一次域名状态,一旦域名被正式删除,就发封邮件通知我,这样就不用频繁手动检查域名状态了。

写脚本时发现一个有趣的现象,使用whois命令查询域名状态时,它给我返回了两组信息,而且这两组信息的域名状态竟然是不一致的,让人非常好奇,所以特意了解了一下whois的机制,记录在这里。

$ whois $DOMAIN | grep "Domain Status"Domain Status: pendingDelete https://icann.org/epp#redemptionPeriod
Domain Status: pendingDelete https://icann.org/epp#ok

在whois返回的两组信息中,第一组来自注册局(Registry,如VeriSign),第二组来自注册商(Registrar,如阿里云),注册商通常拥有比注册局更加详细的域名信息。whois会执行递归查询:首先从注册局查询域名信息,注册局返回的信息中包含注册商的whois服务器,然后再向注册商查询域名信息。调用whois命令时加上--verbose参数可以观察到这个过程:

$ whois $DOMAIN --verbose | grep -E "Using server|Registrar WHOIS Server"
Using server whois.verisign-grs.com.Registrar WHOIS Server: whois.paycenter.com.cn
Using server whois.paycenter.com.cn.
Registrar WHOIS Server: whois.paycenter.com.cn

那么问题来了:注册商whois服务器是从注册局查询得来的,那注册局whois服务器是从哪里来的呢?答案是硬编码。whois命令源码中包含一个tld_serv_list文件,里面包含各顶级域名的注册局whois服务器,以下是该文件的节选:

...
.com	VERISIGN whois.verisign-grs.com.za.net	whois.za.net
.net	VERISIGN whois.verisign-grs.com.eu.org	whois.eu.org
.za.org	whois.za.org
.org	whois.pir.org.edu	whois.educause.edu
.gov	whois.dotgov.gov
.int	whois.iana.org
.mil	NONE
...

既然whois信息保存在不止一个地方,那么由于数据同步的延迟,有时信息不一致也就不足为奇了,那到底该以哪边为准呢?就域名状态而言,应当以注册局的信息为准,https://lookup.icann.org/en/faq里面提供了各字段的数据源,以下是摘录:

Result LabelDescriptionSource
Domain Information
NameThe name of the domain name which was entered into the lookup tool.Registry
Internationalized Domain NameThe non-ASCII character name of the domain name which was entered into the lookup tool, if applicable.Registry
Registry Domain IDRegistry-unique identifier for a domain name.Registry
Domain StatusThe status of a domain name registration. Every domain has at least one status code, but they can also have more than one status code. See EPP Status Codes for more info.Registry
NameserversInformation regarding the domain name’s DNS nameservers. To include nameserver unicode name and IP addresses, where applicable.Registry
Dates
DatesMultiple dates may be displayed in the “Dates” section and can include the date when the domain name registration was created, expires, and updated, as applicable.Registry/Registrar
Contact Information
Registrant, Administrative, Technical, and Billing Contact InformationThe contact information of the registrant, administrative, technical, and billing contacts will appear in this section, where applicable.Registrar
Registrar Information
NameThe name of the registrar sponsoring the domain name’s registration.Registrar
IANA IDThe registrar’s IANA ID from the IANA’s Registrar ID registry (https://www.iana.org/assignments/registrar-ids/registrar-ids.xhtml)Registry
Abuse contact emailThe abuse contact email address of the registrar.Registrar
Abuse contact phoneThe abuse contact telephone number of the registrar.Registrar

我关心的是域名状态这个信息,为了防止从注册商那里获取到过时的数据,可以使用-h选项指定只从注册局获取数据:

$ whois $DOMAIN -h whois.verisign-grs.com --verbose | grep -E "Using server|Domain Status"
Using server whois.verisign-grs.com.Domain Status: ok https://icann.org/epp#redemptionPeriod

后来又改用js,在js中使用whois模块时也有类似的问题,需要指定server参数和follow参数来防止对注册商服务器进行查询:

whois.lookup(domain, { server: "whois.verisign-grs.com", follow: 0 }, (err, data) => {if (err) return reject(err);let statusLines = data.split("\n").filter(line => /Domain Status/i.test(line)).map(line => {const match = line.match(/Domain Status:\s+(\w+)/i);return match ? match[1] : "";}).sort().join("\n");if (statusLines === "") {statusLines = "(empty)";}resolve(statusLines);
});

不过最终的结局是仍然没能注册上这个域名,今天早上醒来,发现域名已经被人注册了,域名状态在半夜两点多发生了变化,从pendingDelete状态直接变更为了ok。这个域名就是我名字的全拼,有9个字母,不知道有啥稀罕的┑( ̄Д  ̄)┍

http://www.xdnf.cn/news/2746.html

相关文章:

  • 【Linux】Java 开发者的 Linux 常用命令指南
  • 2024ICPC成都题解
  • Golang实现函数默认参数
  • 人工智能数学基础(一):人工智能与数学
  • 动态规划问题 -- 斐波那契数列模型(解码方法)
  • etcd 的安装及使用
  • 软件评测师考点重点知识
  • ubuntu安装docker,conda,tmux,btop,nvitop
  • 一种用于从视网膜图像中识别疾病的 BERT 式自监督学习 CNN
  • 大模型训练平台:重构 AI 研发范式的智慧基建
  • MCU内存映射技术详解
  • python数据分析(五):Pandas 数据检索技术
  • 鸢尾花(Iris)数据集的多模型分类与可视化分析工具
  • openai agents sdk实战-基于Ollama+qwen2.5+milvus+bge-large-zh-v1.5实现本地知识库
  • 在 C# .NET 中驾驭 JSON:使用 Newtonsoft.Json 进行解析与 POST 请求实战
  • 动态规划
  • 在g2o中,顶点(Vertex)和边(Edge)插入到概率图的流程
  • 迈瑞医疗:国际业务增长21.28% 发展中国家成重要增长引擎
  • 如何修复卡在恢复模式下的 iPhone:简短指南
  • 配置管理平台Nacos01:基础安装教程和启动运行
  • 第十五届中国国际道路交通安全产品博览会回顾
  • 2025年ISA Trans SCI2区TOP:超级哈里斯鹰算法Super-HHO+高功率机车悬挂载荷偏差控制,深度解析+性能实测
  • 5G育种技术之植物性状订制
  • 智慧健康养老实训室建设方案:科技引领养老健康服务人才培养
  • 第十六节:开放性问题-Vue与React Hooks对比
  • 使用阿里云 CDN 保护网站真实 IP:完整配置指南
  • Wireshark快速入门--对启动的后端程序进行抓包
  • 杰里芯片 7083G 之通话数据dump
  • Java基础361问第16问——枚举为什么导致空指针?
  • GPU虚拟化实现(五)