# Install using: sudo su -c "bash <(wget -qO- /url/to/install-bind.sh)" # Make sure script is ran as root if [[ $EUID -ne 0 ]]; then exec sudo /bin/bash "$0" "$@" fi REALUSER=$(logname) apt update -qq 2>>install.log ufw status >/dev/null 2>&1 || ( echo "Installing UFW..." apt install ufw -y 2>>install.log ufw default allow outgoing 2>>install.log ufw default deny incoming 2>>install.log ufw allow ssh 2>>install.log ufw enable 2>>install.log ) nslookup 127.0.0.1 >/dev/null 2>&1 || ( echo "Installing DNS utils..." apt install dnsutils -y 2>>install.log ) named -v >/dev/null 2>&1 || ( echo "Installing BIND9..." apt install bind9 -y 2>>install.log && ufw allow Bind9 2>>install.log && nslookup google.com 127.0.0.1 ) if ! grep -q "listen-on {" "/etc/bind/named.conf.options"; then sed -i -e 's/^};/\tlisten-on { any; };\n};/mig' /etc/bind/named.conf.options fi if ! grep -q "allow-query" "/etc/bind/named.conf.options"; then sed -i -e 's/^};/\tallow-query { any; };\n};/mig' /etc/bind/named.conf.options fi if ! grep -q "forwarders { 1" "/etc/bind/named.conf.options"; then sed -i -e 's/^};/\tforwarders { 1.1.1.1; 8.8.8.8; 8.8.4.4; };\n};/mig' /etc/bind/named.conf.options fi named-checkconf && systemctl restart bind9 echo 'Installation complete'