rndc.py got 'NotImplementedError: Wrong message version'
dear All.
I'm trying to delete a zone in catalog zone using python. the script is adopted (to Python 3.9.2) from catz-del.py of https://kb.isc.org/docs/aa-01401
here is the script.
import sys
import os
import isc
import dns.query
import dns.update
import dns.name
import hashlib
ZONEPATH='/var/cache/bind/'
MASTERS=['192.168.1.101']
SERVER = '192.168.8.78'
DNSPORT=53
RNDCPORT=9953
RNDCALGO='sha256'
RNDCKEY='1234abcd8765'
CATZONE='catalog.example'
PTR_EXPIRE = 31622400
PRIMARIES = ';'.join(MASTERS)
def hashzones(domain):
hash = hashlib.sha1(dns.name.from_text(domain).to_wire()).hexdigest()
return f'{hash}.zones'
def del_zone(name):
# Update catalog zone
update = dns.update.Update(CATZONE)
update.delete(f'{hashzones(name)}','ptr')
response = dns.query.tcp(update, SERVER, port=DNSPORT)
if response.rcode() != 0:
raise Exception(f"Error updating catalog zone: {response.rcode()}" )
# Delete zone from primary using RNDC
r = isc.rndc((SERVER, DNSPORT), RNDCALGO, RNDCKEY)
response = r.call(f'delzone {name}')
if response['result'] != b'0':
raise Exception(f"Error deleting zone from primary: {response['err']}" )
del_zone(sys.argv[1])
I Got error when try to run it
(venv) debian@risetdns01:~/catzman$ python ./delzone.py domain20.bino
Traceback (most recent call last):
File "/home/debian/catzman/./delzone.py", line 40, in <module>
del_zone(sys.argv[1])
File "/home/debian/catzman/./delzone.py", line 35, in del_zone
r = isc.rndc((SERVER, DNSPORT), RNDCALGO, RNDCKEY)
File "/home/debian/catzman/isc/rndc.py", line 54, in __init__
self.__connect_login()
File "/home/debian/catzman/isc/rndc.py", line 158, in __connect_login
msg = self.__command(type="null")
File "/home/debian/catzman/isc/rndc.py", line 139, in __command
raise NotImplementedError("Wrong message version %d" % version)
NotImplementedError: Wrong message version 2147549184
while from my bind9 log file, I got
13-Mar-2024 22:35:29.991 update: info: client @0x7ff0a4030080 192.168.8.78#33920: updating zone 'catalog.example/IN': deleting rrset at '5858ea66ec75231963ecb03723e1ce3295e23349.zones.catalog.example' PTR
13-Mar-2024 22:35:29.991 client: debug 1: client @0x7ff0a40322c0 192.168.8.78#33926: message parsing failed: bad label type
my isc python module version '9.16.48-Debian' Its /usr/lib/python3/dist-packages/isc/init.py since it cannot accessed directly when I use venv
My named details :
root@risetdns01:~# named -V
BIND 9.16.48-Debian (Extended Support Version) <id:0dab57e>
running on Linux x86_64 5.10.0-28-amd64 #1 SMP Debian 5.10.209-2 (2024-01-31)
built by make with '--build=x86_64-linux-gnu' '--prefix=/usr' '--includedir=/usr/include' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--sysconfdir=/etc' '--localstatedir=/var' '--disable-option-checking' '--disable-silent-rules' '--libdir=/usr/lib/x86_64-linux-gnu' '--runstatedir=/run' '--disable-maintainer-mode' '--disable-dependency-tracking' '--libdir=/usr/lib/x86_64-linux-gnu' '--sysconfdir=/etc/bind' '--with-python=python3' '--localstatedir=/' '--enable-threads' '--enable-largefile' '--with-libtool' '--enable-shared' '--enable-static' '--with-gost=no' '--with-openssl=/usr' '--with-gssapi=/usr' '--with-libidn2' '--with-json-c' '--with-lmdb=/usr' '--with-gnu-ld' '--with-maxminddb' '--with-atf=no' '--enable-ipv6' '--enable-rrl' '--enable-filter-aaaa' '--disable-native-pkcs11' '--enable-dnstap' 'build_alias=x86_64-linux-gnu' 'CFLAGS=-g -O2 -ffile-prefix-map=/build/reproducible-path/bind9-9.16.48=. -fstack-protector-strong -Wformat -Werror=format-security -fno-strict-aliasing -fno-delete-null-pointer-checks -DNO_VERSION_DATE -DDIG_SIGCHASE' 'LDFLAGS=-Wl,-z,relro -Wl,-z,now' 'CPPFLAGS=-Wdate-time -D_FORTIFY_SOURCE=2'
compiled by GCC 10.2.1 20210110
compiled with OpenSSL version: OpenSSL 1.1.1w 11 Sep 2023
linked to OpenSSL version: OpenSSL 1.1.1w 11 Sep 2023
compiled with libuv version: 1.40.0
linked to libuv version: 1.40.0
compiled with libxml2 version: 2.9.10
linked to libxml2 version: 20910
compiled with json-c version: 0.15
linked to json-c version: 0.15
compiled with zlib version: 1.2.11
linked to zlib version: 1.2.11
linked to maxminddb version: 1.5.2
compiled with protobuf-c version: 1.3.3
linked to protobuf-c version: 1.3.3
threads support is enabled
DNSSEC algorithms: RSASHA1 NSEC3RSASHA1 RSASHA256 RSASHA512 ECDSAP256SHA256 ECDSAP384SHA384 ED25519 ED448
DS algorithms: SHA-1 SHA-256 SHA-384
HMAC algorithms: HMAC-MD5 HMAC-SHA1 HMAC-SHA224 HMAC-SHA256 HMAC-SHA384 HMAC-SHA512
TKEY mode 2 support (Diffie-Hellman): yes
TKEY mode 3 support (GSS-API): yes
default paths:
named configuration: /etc/bind/named.conf
rndc configuration: /etc/bind/rndc.conf
DNSSEC root key: /etc/bind/bind.keys
nsupdate session key: //run/named/session.key
named PID file: //run/named/named.pid
named lock file: //run/named/named.lock
geoip-directory: /usr/share/GeoIP
Problem is not occur with 'add zone'
Kindly please tell me what to check or do to fix this problem.
sincerely
-bino-