mirror of
https://github.com/pivpn/pivpn.git
synced 2025-02-22 11:08:19 +00:00
feat(install): support configuring Pi-hole v6
This commit is contained in:
parent
2cafbbf997
commit
cc909fd82e
2 changed files with 24 additions and 14 deletions
|
@ -21,7 +21,7 @@ pivpnFilesDir="/usr/local/src/pivpn"
|
||||||
pivpnScriptDir="/opt/pivpn"
|
pivpnScriptDir="/opt/pivpn"
|
||||||
GITBIN="/usr/bin/git"
|
GITBIN="/usr/bin/git"
|
||||||
|
|
||||||
piholeSetupVars="/etc/pihole/setupVars.conf"
|
piholeVersions="/etc/pihole/versions"
|
||||||
dnsmasqConfig="/etc/dnsmasq.d/02-pivpn.conf"
|
dnsmasqConfig="/etc/dnsmasq.d/02-pivpn.conf"
|
||||||
|
|
||||||
dhcpcdFile="/etc/dhcpcd.conf"
|
dhcpcdFile="/etc/dhcpcd.conf"
|
||||||
|
@ -2359,11 +2359,19 @@ setupPiholeDNS() {
|
||||||
# Then create an empty hosts file or clear if it exists.
|
# Then create an empty hosts file or clear if it exists.
|
||||||
${SUDO} bash -c "> /etc/pivpn/hosts.${VPN}"
|
${SUDO} bash -c "> /etc/pivpn/hosts.${VPN}"
|
||||||
|
|
||||||
# Setting Pi-hole to "Listen on all interfaces" allows
|
# shellcheck disable=SC1090
|
||||||
# dnsmasq to listen on the VPN interface while permitting
|
CORE_VERSION="$(source "$piholeVersions" && echo "${CORE_VERSION}")"
|
||||||
# queries only from hosts whose address is on the LAN and
|
if [ "$(echo -e 'v6.0.0\n'"${CORE_VERSION}" | sort -V | head -n 1)" = "v6.0.0" ]; then
|
||||||
# VPN subnets.
|
# Running Pi-hole v6 or later
|
||||||
${SUDO} pihole -a -i local
|
${SUDO} pihole-FTL --config dns.listeningMode LOCAL
|
||||||
|
${SUDO} pihole-FTL --config misc.etc_dnsmasq_d true
|
||||||
|
else
|
||||||
|
# Setting Pi-hole to "Listen on all interfaces" allows
|
||||||
|
# dnsmasq to listen on the VPN interface while permitting
|
||||||
|
# queries only from hosts whose address is on the LAN and
|
||||||
|
# VPN subnets.
|
||||||
|
${SUDO} pihole -a -i local
|
||||||
|
fi
|
||||||
|
|
||||||
# Use the Raspberry Pi VPN IP as DNS server.
|
# Use the Raspberry Pi VPN IP as DNS server.
|
||||||
pivpnDNS1="${vpnGw}"
|
pivpnDNS1="${vpnGw}"
|
||||||
|
@ -2387,8 +2395,7 @@ setupPiholeDNS() {
|
||||||
askClientDNS() {
|
askClientDNS() {
|
||||||
if [[ "${runUnattended}" == 'true' ]]; then
|
if [[ "${runUnattended}" == 'true' ]]; then
|
||||||
if [[ "${usePiholeDNS}" == 'true' ]] \
|
if [[ "${usePiholeDNS}" == 'true' ]] \
|
||||||
&& command -v pihole > /dev/null \
|
&& command -v pihole > /dev/null; then
|
||||||
&& [[ -r "${piholeSetupVars}" ]]; then
|
|
||||||
setupPiholeDNS
|
setupPiholeDNS
|
||||||
return
|
return
|
||||||
elif [[ -z "${pivpnDNS1}" ]] \
|
elif [[ -z "${pivpnDNS1}" ]] \
|
||||||
|
@ -2438,11 +2445,6 @@ askClientDNS() {
|
||||||
--yesno "We have detected a Pi-hole installation, \
|
--yesno "We have detected a Pi-hole installation, \
|
||||||
do you want to use it as the DNS server for the VPN, so you \
|
do you want to use it as the DNS server for the VPN, so you \
|
||||||
get ad blocking on the go?" "${r}" "${c}"; then
|
get ad blocking on the go?" "${r}" "${c}"; then
|
||||||
if [[ ! -r "${piholeSetupVars}" ]]; then
|
|
||||||
err "::: Unable to read ${piholeSetupVars}"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
setupPiholeDNS
|
setupPiholeDNS
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -16,6 +16,7 @@ c=$((c < 70 ? 70 : c))
|
||||||
|
|
||||||
PKG_MANAGER="apt-get"
|
PKG_MANAGER="apt-get"
|
||||||
PKG_REMOVE="${PKG_MANAGER} -y remove --purge"
|
PKG_REMOVE="${PKG_MANAGER} -y remove --purge"
|
||||||
|
piholeVersions="/etc/pihole/versions"
|
||||||
dnsmasqConfig="/etc/dnsmasq.d/02-pivpn.conf"
|
dnsmasqConfig="/etc/dnsmasq.d/02-pivpn.conf"
|
||||||
setupVarsFile="setupVars.conf"
|
setupVarsFile="setupVars.conf"
|
||||||
setupConfigDir="/etc/pivpn"
|
setupConfigDir="/etc/pivpn"
|
||||||
|
@ -250,7 +251,14 @@ removeAll() {
|
||||||
|
|
||||||
if [[ -f "${dnsmasqConfig}" ]]; then
|
if [[ -f "${dnsmasqConfig}" ]]; then
|
||||||
rm -f "${dnsmasqConfig}"
|
rm -f "${dnsmasqConfig}"
|
||||||
pihole restartdns
|
# shellcheck disable=SC1090
|
||||||
|
CORE_VERSION="$(source "$piholeVersions" && echo "${CORE_VERSION}")"
|
||||||
|
if [ "$(echo -e 'v6.0.0\n'"${CORE_VERSION}" | sort -V | head -n 1)" = "v6.0.0" ]; then
|
||||||
|
# Running Pi-hole v6 or later
|
||||||
|
pihole reloaddns
|
||||||
|
else
|
||||||
|
pihole restartdns reload
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo ":::"
|
echo ":::"
|
||||||
|
|
Loading…
Add table
Reference in a new issue