diff --git a/nsupdate/main/dnstools.py b/nsupdate/main/dnstools.py index ce30430..4daff10 100644 --- a/nsupdate/main/dnstools.py +++ b/nsupdate/main/dnstools.py @@ -28,6 +28,7 @@ import random import struct import dns.inet +import dns.message import dns.name import dns.resolver import dns.query @@ -256,7 +257,7 @@ def query_ns(fqdn, rdtype, prefer_primary=False): ip = str(list(answer)[0]) logger.debug("query: %s answer: %s" % (fqdn, ip)) return ip - except (dns.resolver.Timeout, dns.resolver.NoNameservers) as e: # socket.error also? + except (dns.resolver.Timeout, dns.resolver.NoNameservers, dns.message.UnknownTSIGKey) as e: # socket.error also? logger.warning("error when querying for name '%s' in zone '%s' with rdtype '%s' [%s]." % ( fqdn.host, origin, rdtype, str(e))) set_ns_availability(origin, False) diff --git a/nsupdate/main/models.py b/nsupdate/main/models.py index e04d5f3..5cc69ca 100644 --- a/nsupdate/main/models.py +++ b/nsupdate/main/models.py @@ -7,6 +7,7 @@ import time import base64 import dns.resolver +import dns.message from django.db import models from django.contrib.auth import get_user_model @@ -288,7 +289,8 @@ class Host(models.Model): return dnstools.query_ns(self.get_fqdn(), record) except (dns.resolver.NXDOMAIN, dns.resolver.NoAnswer): return None - except (dns.resolver.NoNameservers, dns.resolver.Timeout, dnstools.NameServerNotAvailable): + except (dns.resolver.NoNameservers, dns.resolver.Timeout, dnstools.NameServerNotAvailable, + dns.message.UnknownTSIGKey): return _('error') def get_ipv4(self):