summaryrefslogtreecommitdiff
path: root/convert.sh
blob: f325d0c50cc6afdb670ef5eea0c46aa75bf8e9fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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!"