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

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个字母,不知道有啥稀罕的┑( ̄Д  ̄)┍

相关文章:

  • 【权限模型】RBAC模型详解
  • Spring Security源码解析
  • DeepSeek+Dify之三工作流引用知识库案例
  • 解锁服务器迁移的未来:《2025 服务器迁移效率白皮书》(附下载)
  • 安卓开发学习随记
  • Redis 常见问题深度剖析与全方位解决方案指南
  • 「地平线」创始人余凯:自动驾驶尚未成熟,人形机器人更无从谈起
  • 【Java学习笔记】传参机制
  • 仙宫云ComfyUI —【Wan2.1】AI视频生成部署
  • uniapp利用生命周期函数实现后台常驻示例
  • 代码随想录算法训练营第二十九天
  • 《淘宝 API 数据湖构建:实时商品详情入湖 + Apache Kafka 流式处理指南》
  • 为什么使用ThreadLocal后要调用remove()方法呢?
  • Springboot整合阿里云腾讯云发送短信验证码 可随时切换短信运营商
  • 数智双翼,生态共赢:中钧科技“双帮”如何领航企业全域升级?
  • 【java】接口
  • OpenResty深度解析:从卓伊凡的”隐形主流”论看其深度原理与应用生态-卓伊凡
  • Label Studio 软件介绍及安装使用说明
  • QGIS+mcp的安装和使用
  • 【零基础入门】ASP.NET Core快速搭建第一个Web应用
  • 杨国荣︱学术上的立此存照——《故旧往事,欲说还休》读后
  • 长三角铁路“五一”假期运输今启动:预计发送旅客量增6%,5月1日当天有望创新高
  • 君亭酒店:2024年营业收入约6.76亿元, “酒店行业传统增长模式面临巨大挑战”
  • 葡萄牙、西班牙突发大范围停电,交通和通信服务受到严重影响
  • 海南儋州市委副书记任延新已赴市人大常委会履新
  • 黄仁勋访华期间表示希望继续与中国合作,贸促会回应