mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-12-26 14:50:17 +00:00
Add NOERROR/NXDOMAIN support in the DNS resolution test
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
parent
c86e7b3f96
commit
635b4e952f
1 changed files with 9 additions and 1 deletions
|
@ -781,8 +781,16 @@ dig_at() {
|
||||||
if [ -n "${addresses}" ]; then
|
if [ -n "${addresses}" ]; then
|
||||||
while IFS= read -r local_address ; do
|
while IFS= read -r local_address ; do
|
||||||
# Check if Pi-hole can use itself to block a domain
|
# Check if Pi-hole can use itself to block a domain
|
||||||
if local_dig=$(dig +tries=1 +time=2 -"${protocol}" "${random_url}" @"${local_address}" +short "${record_type}"); then
|
if local_dig="$(dig +tries=1 +time=2 -"${protocol}" "${random_url}" @"${local_address}" "${record_type}")"; then
|
||||||
# If it can, show success
|
# If it can, show success
|
||||||
|
if [[ "${local_dig}" == *"status: NOERROR"* ]]; then
|
||||||
|
local_dig="NOERROR"
|
||||||
|
elif [[ "${local_dig}" == *"status: NXDOMAIN"* ]]; then
|
||||||
|
local_dig="NXDOMAIN"
|
||||||
|
else
|
||||||
|
# Extract the IPv4/6 address from the output
|
||||||
|
local_dig="$(echo "${local_dig}" | grep -Eo '[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*|([0-9a-f]{0,4}:){1,7}[0-9a-f]{0,4}')"
|
||||||
|
fi
|
||||||
log_write "${TICK} ${random_url} ${COL_GREEN}is ${local_dig}${COL_NC} on ${COL_CYAN}${iface}${COL_NC} (${COL_CYAN}${local_address}${COL_NC})"
|
log_write "${TICK} ${random_url} ${COL_GREEN}is ${local_dig}${COL_NC} on ${COL_CYAN}${iface}${COL_NC} (${COL_CYAN}${local_address}${COL_NC})"
|
||||||
else
|
else
|
||||||
# Otherwise, show a failure
|
# Otherwise, show a failure
|
||||||
|
|
Loading…
Reference in a new issue