mirror of
https://github.com/pi-hole/pi-hole
synced 2024-12-22 14:58:08 +00:00
Merge pull request #849 from pi-hole/aManHasNoNameResolution
[BugFix] A man has no name resolution
This commit is contained in:
commit
21fc6344bf
@ -20,6 +20,12 @@
|
||||
# OR IN /etc/dnsmasq.conf #
|
||||
###############################################################################
|
||||
|
||||
address=/pi.hole/@IPv4@
|
||||
address=/pi.hole/@IPv6@
|
||||
|
||||
address=/@HOSTNAME@/@IPv4@
|
||||
address=/@HOSTNAME@/@IPv6@
|
||||
|
||||
addn-hosts=/etc/pihole/gravity.list
|
||||
|
||||
domain-needed
|
||||
|
@ -540,6 +540,37 @@ version_check_dnsmasq() {
|
||||
else
|
||||
sed -i '/^server=@DNS2@/d' ${dnsmasq_pihole_01_location}
|
||||
fi
|
||||
|
||||
#sed -i "s/@HOSTNAME@/$hostname/" ${dnsmasq_pihole_01_location}
|
||||
|
||||
if [[ -f /etc/hostname ]]; then
|
||||
hostname=$(</etc/hostname)
|
||||
elif [ -x "$(command -v hostname)" ]; then
|
||||
hostname=$(hostname -f)
|
||||
fi
|
||||
|
||||
#Replace IPv4 and IPv6 tokens in 01-pihole.conf for pi.hole resolution.
|
||||
if [[ "${IPv4_address}" != "" ]]; then
|
||||
tmp=${IPv4_address%/*}
|
||||
sed -i "s/@IPv4@/$tmp/" ${dnsmasq_pihole_01_location}
|
||||
else
|
||||
sed -i '/^address=\/pi.hole\/@IPv4@/d' ${dnsmasq_pihole_01_location}
|
||||
sed -i '/^address=\/@HOSTNAME@\/@IPv4@/d' ${dnsmasq_pihole_01_location}
|
||||
fi
|
||||
|
||||
if [[ "${IPv6_address}" != "" ]]; then
|
||||
sed -i "s/@IPv6@/$IPv6_address/" ${dnsmasq_pihole_01_location}
|
||||
else
|
||||
sed -i '/^address=\/pi.hole\/@IPv6@/d' ${dnsmasq_pihole_01_location}
|
||||
sed -i '/^address=\/@HOSTNAME@\/@IPv6@/d' ${dnsmasq_pihole_01_location}
|
||||
fi
|
||||
|
||||
if [[ "${hostname}" != "" ]]; then
|
||||
sed -i "s/@HOSTNAME@/$hostname/" ${dnsmasq_pihole_01_location}
|
||||
else
|
||||
sed -i '/^address=\/@HOSTNAME@*/d' ${dnsmasq_pihole_01_location}
|
||||
fi
|
||||
|
||||
sed -i 's/^#conf-dir=\/etc\/dnsmasq.d$/conf-dir=\/etc\/dnsmasq.d/' ${dnsmasq_conf}
|
||||
}
|
||||
|
||||
|
11
gravity.sh
11
gravity.sh
@ -241,31 +241,20 @@ gravity_unique() {
|
||||
gravity_hostFormat() {
|
||||
# Format domain list as "192.168.x.x domain.com"
|
||||
echo "::: Formatting domains into a HOSTS file..."
|
||||
if [[ -f /etc/hostname ]]; then
|
||||
hostname=$(</etc/hostname)
|
||||
elif [ -x "$(command -v hostname)" ]; then
|
||||
hostname=$(hostname -f)
|
||||
else
|
||||
echo "::: Error: Unable to determine fully qualified domain name of host"
|
||||
fi
|
||||
|
||||
# Check vars from setupVars.conf to see if we're using IPv4, IPv6, Or both.
|
||||
if [[ -n "${IPv4_address}" && -n "${IPv6_address}" ]];then
|
||||
|
||||
# Both IPv4 and IPv6
|
||||
echo -e "$IPv4_address $hostname\n$IPv6_address $hostname\n$IPv4_address pi.hole\n$IPv6_address pi.hole" > ${piholeDir}/${accretionDisc}
|
||||
cat ${piholeDir}/${eventHorizon} | awk -v ipv4addr="$IPv4_address" -v ipv6addr="$IPv6_address" '{sub(/\r$/,""); print ipv4addr" "$0"\n"ipv6addr" "$0}' >> ${piholeDir}/${accretionDisc}
|
||||
|
||||
elif [[ -n "${IPv4_address}" && -z "${IPv6_address}" ]];then
|
||||
|
||||
# Only IPv4
|
||||
echo -e "$IPv4_address $hostname\n$IPv4_address pi.hole" > ${piholeDir}/${accretionDisc}
|
||||
cat ${piholeDir}/${eventHorizon} | awk -v ipv4addr="$IPv4_address" '{sub(/\r$/,""); print ipv4addr" "$0}' >> ${piholeDir}/${accretionDisc}
|
||||
|
||||
elif [[ -z "${IPv4_address}" && -n "${IPv6_address}" ]];then
|
||||
|
||||
# Only IPv6
|
||||
echo -e "$IPv6_address $hostname\n$IPv6_address pi.hole" > ${piholeDir}/${accretionDisc}
|
||||
cat ${piholeDir}/${eventHorizon} | awk -v ipv6addr="$IPv6_address" '{sub(/\r$/,""); print ipv6addr" "$0}' >> ${piholeDir}/${accretionDisc}
|
||||
|
||||
elif [[ -z "${IPv4_address}" && -z "${IPv6_address}" ]];then
|
||||
|
Loading…
Reference in New Issue
Block a user