Hi!
In the last few days I have tried a new service for DDNS, nsupdate.info.
I have some problems with the service and I have been able to reproduce the
problem in a small sample script.
The attached script does update my bind9 instance but reports SERVFAIL for
Knot.
Unfortunately I still have not been able to get Knot to write more
extensive log entries.
The script uses the Python dns library from Nominum.
This is the output of the script (first update to bind then to knot)
$ python example.py
performing add for name ddns.example.com and origin example.com with rdtype
A and ipaddr 2.3.4.5
performing add for name ddns.example.com and origin example.com with rdtype
A and ipaddr 2.3.4.5
DNS error [SERVFAIL] performing add for name ddns.example.com and origin
example.com with rdtype A and ipaddr 2.3.4.5
Knot didn't log anything at all. (Any hints for that config would be
welcome.) Bind did log the following
Oct 5 21:07:49 localhost named[23792]: client beef::cafe#59322/key
example.com: updating zone 'example.com/IN': adding an RR at '
ddns.example.com.' A
Some error in the script? Could someone point me to a working script?
Any hints are welcome!
Kind regards from Stockholm
Ulrich
--
Ulrich Wisser
[email protected]
import os
import time
import socket
import dns.inet
import dns.name
import dns.resolver
import dns.query
import dns.update
import dns.tsig
import dns.tsigkeyring
UPDATE_TIMEOUT = float(os.environ.get('DNS_UPDATE_TIMEOUT', '20.0'))
Timeout = dns.resolver.Timeout
NoNameservers = dns.resolver.NoNameservers
def update_ns(nameserver, origin, name, rdtype='A', ipaddr=None, action='upd', ttl=60):
upd = dns.update.Update(origin,
keyring=dns.tsigkeyring.from_text({'example.com.': 'SECRET'}),
keyalgorithm=dns.tsig.HMAC_SHA256
)
if action == 'add':
upd.add(name, ttl, rdtype, ipaddr)
elif action == 'del':
upd.delete(name, rdtype)
elif action == 'upd':
upd.replace(name, ttl, rdtype, ipaddr)
print("performing %s for name %s and origin %s with rdtype %s and ipaddr %s" % (action, name, origin, rdtype, ipaddr))
try:
response = dns.query.tcp(upd, nameserver, timeout=UPDATE_TIMEOUT)
rcode = response.rcode()
if rcode != dns.rcode.NOERROR:
rcode_text = dns.rcode.to_text(rcode)
print("DNS error [%s] performing %s for name %s and origin %s with rdtype %s and ipaddr %s" % (rcode_text, action, name, origin, rdtype, ipaddr))
except socket.error as e:
print("socket.error [%s] - zone: %s" % (str(e), origin, ))
except EOFError as e:
print("EOFError [%s] - zone: %s" % (str(e), origin, ))
except dns.exception.Timeout:
print("timeout when performing %s for name %s and origin %s with rdtype %s and ipaddr %s" % (action, name, origin, rdtype, ipaddr))
except dns.tsig.PeerBadSignature:
print("PeerBadSignature - shared secret mismatch? zone: %s" % (origin, ))
except dns.tsig.PeerBadKey:
print("PeerBadKey - shared secret mismatch? zone: %s" % (origin, ))
except dns.tsig.PeerBadTime:
print("PeerBadTime - DNS server did not like the time we sent. zone: %s" % (origin, ))
except dns.message.UnknownTSIGKey as e:
print("UnknownTSIGKey [%s] - zone: %s" % (str(e), origin, ))
update_ns('dead::beef', 'example.com', 'ddns.example.com.', 'A', '2.3.4.5', 'add')
update_ns('bad::dad', 'example.com', 'ddns.example.com.', 'A', '2.3.4.5', 'add')
_______________________________________________
knot-dns-users mailing list
[email protected]
https://lists.nic.cz/cgi-bin/mailman/listinfo/knot-dns-users