summaryrefslogtreecommitdiffstats
path: root/ipapython
diff options
context:
space:
mode:
Diffstat (limited to 'ipapython')
-rw-r--r--ipapython/ipautil.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/ipapython/ipautil.py b/ipapython/ipautil.py
index 4cee81e64..7509f08c1 100644
--- a/ipapython/ipautil.py
+++ b/ipapython/ipautil.py
@@ -40,7 +40,7 @@ from contextlib import contextmanager
import locale
import collections
-from dns import resolver, rdatatype
+from dns import resolver, rdatatype, reversename
from dns.exception import DNSException, Timeout
import six
from six.moves import input
@@ -1031,6 +1031,22 @@ def host_exists(host):
return True
+def reverse_record_exists(ip_address):
+ """
+ Checks if IP address have some reverse record somewhere.
+ Does not care where it points.
+
+ Returns True/False
+ """
+ reverse = reversename.from_address(str(ip_address))
+ try:
+ resolver.query(reverse, "PTR")
+ except DNSException:
+ # really don't care what exception, PTR is simply unresolvable
+ return False
+ return True
+
+
def check_zone_overlap(zone, raise_on_timeout=True):
root_logger.info("Checking DNS domain %s, please wait ..." % zone)
if not isinstance(zone, DNSName):