Skip to content

Commit 5367a17

Browse files
Update pihole-install.sh (#235)
* Update pihole-install.sh * Added the option to configure Unbound as a forwarding DNS server (using DNS-over-TLS (DoT)). * Simplified the Unbound configuration. The root hints file is actually provided by the dns-root-data package so there is no need to explicitly define it (via the root-hints configuration directive) and wget it. Also, there was no mechanism to update the file after the initial fetch - this will now done by the package manager. * Fix: Unbound (127.0.0.1#5335) would not become active until a configuration change was made and saved or the application was updated. These are the only times (other than during install) that /etc/dnsmasq.d/01-pihole.conf is synced with /etc/pihole/setupVars.conf. Updated the install script to swap out the dns server in /etc/dnsmasq.d/01-pihole.conf similar to /etc/pihole/setupVars.conf. Delete 8.8.4.4 in both files as opposed to commenting it out as the commented out line would never be recycled. * Update pihole.json * Update install/pihole-install.sh Updated the prompt text after code review. Co-authored-by: Håvard Gjøby Thom <[email protected]> --------- Co-authored-by: Håvard Gjøby Thom <[email protected]>
1 parent e622081 commit 5367a17

File tree

2 files changed

+35
-5
lines changed

2 files changed

+35
-5
lines changed

install/pihole-install.sh

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ msg_ok "Installed Pi-hole"
4444

4545
read -r -p "Would you like to add Unbound? <y/N> " prompt
4646
if [[ ${prompt,,} =~ ^(y|yes)$ ]]; then
47+
read -r -p "Unbound is configured as a recursive DNS server by default, would you like it to be configured as a forwarding DNS server (using DNS-over-TLS (DoT)) instead? <y/N> " prompt
4748
msg_info "Installing Unbound"
4849
$STD apt-get install -y unbound
4950
cat <<EOF >/etc/unbound/unbound.conf.d/pi-hole.conf
@@ -73,7 +74,6 @@ server:
7374
infra-cache-slabs: 8
7475
key-cache-slabs: 8
7576
serve-expired: yes
76-
root-hints: /var/lib/unbound/root.hints
7777
serve-expired-ttl: 3600
7878
edns-buffer-size: 1232
7979
prefetch: yes
@@ -94,8 +94,34 @@ EOF
9494
cat <<EOF >/etc/dnsmasq.d/99-edns.conf
9595
edns-packet-max=1232
9696
EOF
97-
wget -qO /var/lib/unbound/root.hints https://www.internic.net/domain/named.root
98-
sed -i -e 's/PIHOLE_DNS_1=8.8.8.8/PIHOLE_DNS_1=127.0.0.1#5335/' -e 's/PIHOLE_DNS_2=8.8.4.4/#PIHOLE_DNS_2=8.8.4.4/' /etc/pihole/setupVars.conf
97+
98+
if [[ ${prompt,,} =~ ^(y|yes)$ ]]; then
99+
cat <<EOF >>/etc/unbound/unbound.conf.d/pi-hole.conf
100+
tls-cert-bundle: "/etc/ssl/certs/ca-certificates.crt"
101+
forward-zone:
102+
name: "."
103+
forward-tls-upstream: yes
104+
forward-first: no
105+
106+
forward-addr: 8.8.8.8@853#dns.google
107+
forward-addr: 8.8.4.4@853#dns.google
108+
forward-addr: 2001:4860:4860::8888@853#dns.google
109+
forward-addr: 2001:4860:4860::8844@853#dns.google
110+
111+
#forward-addr: 1.1.1.1@853#cloudflare-dns.com
112+
#forward-addr: 1.0.0.1@853#cloudflare-dns.com
113+
#forward-addr: 2606:4700:4700::1111@853#cloudflare-dns.com
114+
#forward-addr: 2606:4700:4700::1001@853#cloudflare-dns.com
115+
116+
#forward-addr: 9.9.9.9@853#dns.quad9.net
117+
#forward-addr: 149.112.112.112@853#dns.quad9.net
118+
#forward-addr: 2620:fe::fe@853#dns.quad9.net
119+
#forward-addr: 2620:fe::9@853#dns.quad9.net
120+
EOF
121+
fi
122+
123+
sed -i -e 's/PIHOLE_DNS_1=8.8.8.8/PIHOLE_DNS_1=127.0.0.1#5335/' -e '/PIHOLE_DNS_2=8.8.4.4/d' /etc/pihole/setupVars.conf
124+
sed -i -e 's/server=8.8.8.8/server=127.0.0.1#5335/' -e '/server=8.8.4.4/d' /etc/dnsmasq.d/01-pihole.conf
99125
systemctl enable -q --now unbound
100126
systemctl restart pihole-FTL.service
101127
msg_ok "Installed Unbound"

json/pihole.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@
3737
},
3838
{
3939
"text": "With an option to add Unbound",
40-
"type": "warning"
40+
"type": "info"
41+
},
42+
{
43+
"text": "With an option to configure Unbound as a forwarding DNS server (using DNS-over-TLS (DoT)) as opposed to a recursive DNS server",
44+
"type": "info"
4145
}
4246
]
43-
}
47+
}

0 commit comments

Comments
 (0)