之前发现 WHOIS 退役的时候我就把 whois 命令卸载了转而用 RDAP 查询,因为 whois 查询不到没有 WHOIS 服务器的域名,但是几个 RDAP 服务都有一些问题,比如:
ICANN Lookup (https://lookup.icann.org) 虽然功能正常但是经常需要查询的时候做 Google reCAPTCHA 非常麻烦
RDAP.ORG (https://client.rdap.org) 不知道为什么找不到一些域名的 RDAP URL
官方的 icann-rdap (https://github.com/icann/icann-rdap) 会在没必要的情况下往 .config 里放文件而且 Arch 没有官方包
直到今天我找到了 OpenRDAP 转发服务,可以直接用他们的 API 查询,自动转发给对应域名的 RDAP 服务器返回 JSON 结果,那么就用这么一个 function 就可以完成域名查询了
P.S. 貌似有些域名比如 .im 就是没有 RDAP 服务器,看来还得做一下 WHOIS fallback
ICANN Lookup (https://lookup.icann.org) 虽然功能正常但是经常需要查询的时候做 Google reCAPTCHA 非常麻烦
RDAP.ORG (https://client.rdap.org) 不知道为什么找不到一些域名的 RDAP URL
官方的 icann-rdap (https://github.com/icann/icann-rdap) 会在没必要的情况下往 .config 里放文件而且 Arch 没有官方包
直到今天我找到了 OpenRDAP 转发服务,可以直接用他们的 API 查询,自动转发给对应域名的 RDAP 服务器返回 JSON 结果,那么就用这么一个 function 就可以完成域名查询了
P.S. 貌似有些域名比如 .im 就是没有 RDAP 服务器,看来还得做一下 WHOIS fallback
# Perform RDAP lookup for a domain through the OpenRDAP redirecting service
# Fallback to WHOIS if RDAP lookup fails
function whois() {
# Check that a domain has been provided
if [ -z "$1" ]; then
>&2 echo 'error: no target domain specified'
>&2 echo 'usage: whois <domain>'
return 1
fi
local rdap_output
if rdap_output=$(curl -sSLf "https://www.rdap.net/domain/$1"); then
echo "$rdap_output" | yq -P
else
>&2 echo 'failed to perform RDAP lookup; falling back to WHOIS'
command whois "$1"
fi
}