Create check-dns.sh

This commit is contained in:
spiritLHLS 2023-04-04 19:45:04 +08:00 committed by GitHub
parent 8b41a0da60
commit 39bf505a79
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

14
check-dns.sh Normal file
View file

@ -0,0 +1,14 @@
#!/bin/bash
#from https://github.com/spiritLHLS/pve
DNS_SERVER="8.8.8.8"
RESOLV_CONF="/etc/resolv.conf"
grep -q "^nameserver ${DNS_SERVER}$" ${RESOLV_CONF}
if [ $? -eq 0 ]; then
echo "DNS server ${DNS_SERVER} already exists in ${RESOLV_CONF}."
else
echo "Adding DNS server ${DNS_SERVER} to ${RESOLV_CONF}..."
echo "nameserver ${DNS_SERVER}" >> ${RESOLV_CONF}
fi