diff options
author | doc <doc@filenotfound.org> | 2025-06-29 07:20:14 +0000 |
---|---|---|
committer | doc <doc@filenotfound.org> | 2025-06-29 07:20:14 +0000 |
commit | e5bf3b99d39bac5390bd780b08585f2897caf86d (patch) | |
tree | 45b542a04445bdb3228e4521b0c4b832c9a8ff95 /convert.sh |
Diffstat (limited to 'convert.sh')
-rwxr-xr-x | convert.sh | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/convert.sh b/convert.sh new file mode 100755 index 0000000..f325d0c --- /dev/null +++ b/convert.sh @@ -0,0 +1,62 @@ +#!/bin/bash +set -e + +echo "๐งน Stopping and disabling AdGuardHome..." +systemctl stop AdGuardHome || true +systemctl disable AdGuardHome || true +rm -f /etc/systemd/system/AdGuardHome.service +rm -rf /opt/AdGuardHome +rm -f /usr/bin/AdGuardHome + +echo "๐ฆ Installing Unbound..." +apt update +apt install -y unbound curl + +echo "๐ Fetching root hints..." +curl -o /var/lib/unbound/root.hints https://www.internic.net/domain/named.cache + +echo "๐ Setting up hardened Unbound config..." +cat >/etc/unbound/unbound.conf <<EOF +server: + interface: 0.0.0.0 + access-control: 192.168.0.0/16 allow + access-control: 127.0.0.0/8 allow + + num-threads: $(nproc) + msg-cache-size: 128m + rrset-cache-size: 256m + prefetch: yes + prefetch-key: yes + + auto-trust-anchor-file: "/var/lib/unbound/root.key" + val-permissive-mode: no + + root-hints: "/var/lib/unbound/root.hints" + + qname-minimisation: yes + harden-dnssec-stripped: yes + harden-referral-path: yes + minimal-responses: yes + +remote-control: + control-enable: yes +EOF + +echo "๐ Disabling systemd-resolved stub listener if present..." +if [ -f /etc/systemd/resolved.conf ]; then + sed -i 's/^#*DNSStubListener=.*/DNSStubListener=no/' /etc/systemd/resolved.conf + systemctl restart systemd-resolved +fi + +echo "๐ฆ Restarting Unbound..." +systemctl enable unbound +systemctl restart unbound + +echo "โ
Verifying Unbound is listening..." +ss -ulpn | grep :53 || echo "โ ๏ธ Unbound might not be listening properly." + +echo "๐งช Test locally with:" +echo " dig +dnssec cloudflare.com @127.0.0.1" +echo " dig +dnssec dnssec-failed.org @127.0.0.1" + +echo "๐ Conversion complete. Box is now a recursive DNS resolver!" |