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:
parent
4140796807
commit
e1a3533fbe
|
@ -30,7 +30,7 @@ import json
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
from multiprocessing import Pool
|
from multiprocessing import Pool
|
||||||
from os import path, chdir
|
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 subprocess import check_output, CalledProcessError
|
||||||
from sys import stdout
|
from sys import stdout
|
||||||
from time import time
|
from time import time
|
||||||
|
@ -114,10 +114,11 @@ def scan_host(ip):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
try:
|
try:
|
||||||
|
# attempt to convert IP to hostname, if anything goes wrong, just use the IP
|
||||||
tmp = gethostbyaddr(ip)[0]
|
tmp = gethostbyaddr(ip)[0]
|
||||||
if gethostbyname(tmp) == ip: # check that forward resolves
|
if gethostbyname(tmp) == ip: # check that forward resolves
|
||||||
hostname = tmp
|
hostname = tmp
|
||||||
except herror:
|
except (herror, gaierror):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue