autoDeploy/checkDns.sh

14 lines
341 B
Bash
Raw Permalink Normal View History

2025-03-11 08:52:19 +08:00
#!/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}$"