mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
snmpscan.py: ignore bad DNS config (#8656)
When someone has configured reverse dns that points to an incorrect dns hostname, this should revert to IP properly
This commit is contained in:
@ -30,7 +30,7 @@ import json
|
||||
from collections import namedtuple
|
||||
from multiprocessing import Pool
|
||||
from os import path, chdir
|
||||
from socket import gethostbyname, gethostbyaddr, herror
|
||||
from socket import gethostbyname, gethostbyaddr, herror, gaierror
|
||||
from subprocess import check_output, CalledProcessError
|
||||
from sys import stdout
|
||||
from time import time
|
||||
@ -114,10 +114,11 @@ def scan_host(ip):
|
||||
|
||||
try:
|
||||
try:
|
||||
# attempt to convert IP to hostname, if anything goes wrong, just use the IP
|
||||
tmp = gethostbyaddr(ip)[0]
|
||||
if gethostbyname(tmp) == ip: # check that forward resolves
|
||||
hostname = tmp
|
||||
except herror:
|
||||
except (herror, gaierror):
|
||||
pass
|
||||
|
||||
try:
|
||||
|
Reference in New Issue
Block a user