autoDeploy/checkDns.sh
2025-03-11 08:52:19 +08:00

14 lines
341 B
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# 检查参数个数是否正确
if [ $# -ne 2 ]; then
echo "用法: $0 <域名> <DNS服务器地址>"
exit 1
fi
domain="$1"
dns_server="$2"
# 使用dig命令查询域名对应的IP地址并过滤结果只保留IP地址
dig +short "$domain" @$dns_server | grep -E "^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$"