unbound: use ipv4 on older ubuntu

SpamHaus rejects queries from ipv6.
unbound does not work on ipv6 only servers without do-ip6: true
prefer-ip4 only works on ubuntu 24

this leads to a situation that we cannot support ipv6 only servers with
older ubuntu
This commit is contained in:
Girish Ramakrishnan
2025-06-28 17:56:09 +02:00
parent 0427d08ede
commit 6561a40f2c
3 changed files with 12 additions and 10 deletions

View File

@@ -94,10 +94,12 @@ systemctl restart systemd-journald
usermod -a -G adm ${USER}
log "Setting up unbound"
rm -f /etc/unbound/unbound.conf.d/prefer-ip4.conf # old config file
cp -f "${script_dir}/start/unbound/unbound.conf" /etc/unbound/unbound.conf.d/cloudron-network.conf
unbound_version=$(unbound -V | sed -n 's/^Version \([0-9.]*\)/\1/p')
if vergte "${unbound_version}" "1.19.2"; then
cp "${script_dir}/start/unbound/prefer-ip4.conf" /etc/unbound/unbound.conf.d/cloudron-prefer-ip4.conf
if [[ "${ubuntu_version}" == "20.04" || "${ubuntu_version}" == "22.04" ]]; then
# on older ubuntu, prefer-ip4 option does not exist. do-ip6 has to be disabled because SpamHaus rejects IPv6 queries
# this means we cannot support IPv6 only servers on older ubuntu
sed -e 's/do-ip6: yes/do-ip6: no/' -e 's/prefer-ip4:/# prefer-ip4:/' -i /etc/unbound/unbound.conf.d/cloudron-network.conf
fi
rm -f /etc/unbound/unbound.conf.d/remote-control.conf # on ubuntu 24