mirror of
https://github.com/pi-hole/pi-hole
synced 2025-01-05 13:40:56 +00:00
Merge pull request #1294 from pi-hole/tweak/debugDNS
Tweak DNS debugging
This commit is contained in:
commit
d1e0f3ae18
@ -305,43 +305,61 @@ daemon_check() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
testResolver() {
|
testResolver() {
|
||||||
header_write "Resolver Functions Check"
|
local protocol="${1}"
|
||||||
|
header_write "Resolver Functions Check (IPv${protocol})"
|
||||||
|
local IP="${2}"
|
||||||
|
local g_addr
|
||||||
|
local l_addr
|
||||||
|
local url
|
||||||
|
local testurl
|
||||||
|
local localdig
|
||||||
|
local piholedig
|
||||||
|
local remotedig
|
||||||
|
|
||||||
|
if [[ ${protocol} == "6" ]]; then
|
||||||
|
g_addr="2001:4860:4860::8888"
|
||||||
|
l_addr="::1"
|
||||||
|
r_type="AAAA"
|
||||||
|
else
|
||||||
|
g_addr="8.8.8.8"
|
||||||
|
l_addr="127.0.0.1"
|
||||||
|
r_type="A"
|
||||||
|
fi
|
||||||
|
|
||||||
# Find a blocked url that has not been whitelisted.
|
# Find a blocked url that has not been whitelisted.
|
||||||
TESTURL="doubleclick.com"
|
url=$(shuf -n 1 "${GRAVITYFILE}" | awk -F ' ' '{ print $2 }')
|
||||||
if [ -s "${WHITELISTMATCHES}" ]; then
|
|
||||||
while read -r line; do
|
|
||||||
CUTURL=${line#*" "}
|
|
||||||
if [ "${CUTURL}" != "Pi-Hole.IsWorking.OK" ]; then
|
|
||||||
while read -r line2; do
|
|
||||||
CUTURL2=${line2#*" "}
|
|
||||||
if [ "${CUTURL}" != "${CUTURL2}" ]; then
|
|
||||||
TESTURL="${CUTURL}"
|
|
||||||
break 2
|
|
||||||
fi
|
|
||||||
done < "${WHITELISTMATCHES}"
|
|
||||||
fi
|
|
||||||
done < "${GRAVITYFILE}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
log_write "Resolution of ${TESTURL} from Pi-hole:"
|
testurl="${url:-doubleclick.com}"
|
||||||
LOCALDIG=$(dig "${TESTURL}" @127.0.0.1)
|
|
||||||
if [[ $? = 0 ]]; then
|
|
||||||
log_write "${LOCALDIG}"
|
log_write "Resolution of ${testurl} from Pi-hole (${l_addr}):"
|
||||||
|
if localdig=$(dig -"${protocol}" "${testurl}" @${l_addr} +short "${r_type}"); then
|
||||||
|
log_write "${localdig}"
|
||||||
else
|
else
|
||||||
log_write "Failed to resolve ${TESTURL} on Pi-hole"
|
log_write "Failed to resolve ${testurl} on Pi-hole (${l_addr})"
|
||||||
|
fi
|
||||||
|
log_write ""
|
||||||
|
|
||||||
|
log_write "Resolution of ${testurl} from Pi-hole (${IP}):"
|
||||||
|
if piholedig=$(dig -"${protocol}" "${testurl}" @"${IP}" +short "${r_type}"); then
|
||||||
|
log_write "${piholedig}"
|
||||||
|
else
|
||||||
|
log_write "Failed to resolve ${testurl} on Pi-hole (${IP})"
|
||||||
fi
|
fi
|
||||||
log_write ""
|
log_write ""
|
||||||
|
|
||||||
|
|
||||||
log_write "Resolution of ${TESTURL} from 8.8.8.8:"
|
log_write "Resolution of ${testurl} from ${g_addr}:"
|
||||||
REMOTEDIG=$(dig "${TESTURL}" @8.8.8.8)
|
if remotedig=$(dig -"${protocol}" "${testurl}" @${g_addr} +short "${r_type}"); then
|
||||||
if [[ $? = 0 ]]; then
|
log_write "${remotedig:-NXDOMAIN}"
|
||||||
log_write "${REMOTEDIG}"
|
|
||||||
else
|
else
|
||||||
log_write "Failed to resolve ${TESTURL} on 8.8.8.8"
|
log_write "Failed to resolve ${testurl} on upstream server ${g_addr}"
|
||||||
fi
|
fi
|
||||||
log_write ""
|
log_write ""
|
||||||
|
}
|
||||||
|
|
||||||
|
testChaos(){
|
||||||
|
# Check Pi-hole specific records
|
||||||
|
|
||||||
log_write "Pi-hole dnsmasq specific records lookups"
|
log_write "Pi-hole dnsmasq specific records lookups"
|
||||||
log_write "Cache Size:"
|
log_write "Cache Size:"
|
||||||
@ -349,8 +367,8 @@ testResolver() {
|
|||||||
log_write "Upstream Servers:"
|
log_write "Upstream Servers:"
|
||||||
dig +short chaos txt servers.bind >> ${DEBUG_LOG}
|
dig +short chaos txt servers.bind >> ${DEBUG_LOG}
|
||||||
log_write ""
|
log_write ""
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
checkProcesses() {
|
checkProcesses() {
|
||||||
header_write "Processes Check"
|
header_write "Processes Check"
|
||||||
|
|
||||||
@ -388,50 +406,6 @@ countdown() {
|
|||||||
tuvix=$(( tuvix - 5 ))
|
tuvix=$(( tuvix - 5 ))
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
### END FUNCTIONS ###
|
|
||||||
|
|
||||||
# Gather version of required packages / repositories
|
|
||||||
version_check || echo "REQUIRED FILES MISSING"
|
|
||||||
# Check for newer setupVars storage file
|
|
||||||
source_file "/etc/pihole/setupVars.conf"
|
|
||||||
# Gather information about the running distribution
|
|
||||||
distro_check || echo "Distro Check soft fail"
|
|
||||||
# Gather processor type
|
|
||||||
processor_check || echo "Processor Check soft fail"
|
|
||||||
|
|
||||||
ip_check 6 ${IPV6_ADDRESS}
|
|
||||||
ip_check 4 ${IPV4_ADDRESS}
|
|
||||||
|
|
||||||
daemon_check lighttpd http
|
|
||||||
daemon_check dnsmasq domain
|
|
||||||
daemon_check pihole-FTL 4711
|
|
||||||
checkProcesses
|
|
||||||
testResolver
|
|
||||||
debugLighttpd
|
|
||||||
|
|
||||||
files_check "${DNSMASQFILE}"
|
|
||||||
dir_check "${DNSMASQCONFDIR}"
|
|
||||||
files_check "${WHITELISTFILE}"
|
|
||||||
files_check "${BLACKLISTFILE}"
|
|
||||||
files_check "${ADLISTFILE}"
|
|
||||||
|
|
||||||
|
|
||||||
header_write "Analyzing gravity.list"
|
|
||||||
|
|
||||||
gravity_length=$(grep -c ^ "${GRAVITYFILE}") \
|
|
||||||
&& log_write "${GRAVITYFILE} is ${gravity_length} lines long." \
|
|
||||||
|| log_echo "Warning: No gravity.list file found!"
|
|
||||||
|
|
||||||
header_write "Analyzing pihole.log"
|
|
||||||
|
|
||||||
pihole_length=$(grep -c ^ "${PIHOLELOG}") \
|
|
||||||
&& log_write "${PIHOLELOG} is ${pihole_length} lines long." \
|
|
||||||
|| log_echo "Warning: No pihole.log file found!"
|
|
||||||
|
|
||||||
pihole_size=$(du -h "${PIHOLELOG}" | awk '{ print $1 }') \
|
|
||||||
&& log_write "${PIHOLELOG} is ${pihole_size}." \
|
|
||||||
|| log_echo "Warning: No pihole.log file found!"
|
|
||||||
|
|
||||||
|
|
||||||
# Continuously append the pihole.log file to the pihole_debug.log file
|
# Continuously append the pihole.log file to the pihole_debug.log file
|
||||||
dumpPiHoleLog() {
|
dumpPiHoleLog() {
|
||||||
@ -481,6 +455,59 @@ finalWork() {
|
|||||||
echo "::: A local copy of the Debug log can be found at : /var/log/pihole_debug.log"
|
echo "::: A local copy of the Debug log can be found at : /var/log/pihole_debug.log"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
### END FUNCTIONS ###
|
||||||
|
|
||||||
|
# Gather version of required packages / repositories
|
||||||
|
version_check || echo "REQUIRED FILES MISSING"
|
||||||
|
# Check for newer setupVars storage file
|
||||||
|
source_file "/etc/pihole/setupVars.conf"
|
||||||
|
# Gather information about the running distribution
|
||||||
|
distro_check || echo "Distro Check soft fail"
|
||||||
|
# Gather processor type
|
||||||
|
processor_check || echo "Processor Check soft fail"
|
||||||
|
|
||||||
|
ip_check 6 ${IPV6_ADDRESS}
|
||||||
|
ip_check 4 ${IPV4_ADDRESS}
|
||||||
|
|
||||||
|
daemon_check lighttpd http
|
||||||
|
daemon_check dnsmasq domain
|
||||||
|
daemon_check pihole-FTL 4711
|
||||||
|
checkProcesses
|
||||||
|
|
||||||
|
# Check local/IP/Google for IPv4 Resolution
|
||||||
|
testResolver 4 "${IPV4_ADDRESS%/*}"
|
||||||
|
# If IPv6 enabled, check resolution
|
||||||
|
if [[ "${IPV6_ADDRESS}" ]]; then
|
||||||
|
testResolver 6 "${IPV6_ADDRESS%/*}"
|
||||||
|
fi
|
||||||
|
# Poll dnsmasq Pi-hole specific queries
|
||||||
|
testChaos
|
||||||
|
|
||||||
|
debugLighttpd
|
||||||
|
|
||||||
|
files_check "${DNSMASQFILE}"
|
||||||
|
dir_check "${DNSMASQCONFDIR}"
|
||||||
|
files_check "${WHITELISTFILE}"
|
||||||
|
files_check "${BLACKLISTFILE}"
|
||||||
|
files_check "${ADLISTFILE}"
|
||||||
|
|
||||||
|
|
||||||
|
header_write "Analyzing gravity.list"
|
||||||
|
|
||||||
|
gravity_length=$(grep -c ^ "${GRAVITYFILE}") \
|
||||||
|
&& log_write "${GRAVITYFILE} is ${gravity_length} lines long." \
|
||||||
|
|| log_echo "Warning: No gravity.list file found!"
|
||||||
|
|
||||||
|
header_write "Analyzing pihole.log"
|
||||||
|
|
||||||
|
pihole_length=$(grep -c ^ "${PIHOLELOG}") \
|
||||||
|
&& log_write "${PIHOLELOG} is ${pihole_length} lines long." \
|
||||||
|
|| log_echo "Warning: No pihole.log file found!"
|
||||||
|
|
||||||
|
pihole_size=$(du -h "${PIHOLELOG}" | awk '{ print $1 }') \
|
||||||
|
&& log_write "${PIHOLELOG} is ${pihole_size}." \
|
||||||
|
|| log_echo "Warning: No pihole.log file found!"
|
||||||
|
|
||||||
trap finalWork EXIT
|
trap finalWork EXIT
|
||||||
|
|
||||||
### Method calls for additional logging ###
|
### Method calls for additional logging ###
|
||||||
|
Loading…
Reference in New Issue
Block a user