pve/scripts/check-dns.sh

17 lines
575 B
Bash
Raw Normal View History

2023-04-04 19:45:04 +08:00
#!/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
2023-06-09 13:34:37 +08:00
chattr -i /etc/resolv.conf
2023-04-04 19:45:04 +08:00
echo "Adding DNS server ${DNS_SERVER} to ${RESOLV_CONF}..."
2023-05-14 08:59:34 +08:00
echo -e "nameserver 1.1.1.1\nnameserver 8.8.8.8\nnameserver 8.8.4.4\nnameserver 2606:4700:4700::1111\nnameserver 2001:4860:4860::8888\nnameserver 2001:4860:4860::8844" >> ${RESOLV_CONF}
2023-06-09 13:34:37 +08:00
chattr +i /etc/resolv.conf
2023-04-04 19:45:04 +08:00
fi