【发布时间】:2019-01-15 11:32:17
【问题描述】:
我正在尝试在我的终端上将一些 DNS 记录搜索的批量搜索与 Whois 搜索结合起来。我有一个包含域列表的 CSV 文件,我想运行以下批量搜索器:
- MX搜索:
host -t mx $domain - NS 搜索:
host -t ns $domain
这很容易。
将其与 Whois 搜索结合使用;它只返回一些 Whois 数据的摘要;我需要在 whois 服务器上查询域,这很好: 谁是
我可以使用-h,只记录域名注册人的详细信息,例如电话、国家代码等。我试过这个:
- Whois:
whois -h 'Registrar WHOIS Server:' "domain"这也为我提供了仅注册人详细信息的输出。
因此,当我将所有内容合并到一个 bash 文件中时,我得到:
#!/usr/bin/env bash
file="${1:-input_test1.csv}"
if [[ ! -f "$file" ]]; then
printf 'No file: %s\n' "$file" >&2
exit 1
fi
(
read -r header; printf '%s\n' "$header"
while IFS=, read -r domain; do
mx="$(host -t mx "$domain" | sort | head -1)"
ns="$(host -t ns "$domain" | sort| head -1)"
whois="$(whois -h "$(whois" "$domain" | grep 'Registrar WHOIS Server:') "$domain")
printf '%s,"%s"\n' "$domain" "$mx" "$ns" "$whois"
done
) < "$file"
我很想得到一个包含域的 CSV 输出,mx(只有 1 个),NS(只有 1 个),whois whois is registrant data 如下所示;
Sample Expected Output Screengrab
谢谢。
【问题讨论】: