How to send NOTIFY with dnspython?

76 Views Asked by At

I'm try to write a simple 'notify relay'.

For the start, it will query a SOA record from my test BIND9 server and send the result to dnspython based receiver.

I just made a small modification from https://groups.google.com/g/dnspython-users/c/hUM6ADAEZr8/m/YuvzSZmrCwAJ

Here is my scriptz

import dns.message
import dns.rdataclass
import dns.rdatatype
import dns.query
import dns.opcode
import dns.flags
import dns.resolver

master_dns = '192.168.56.106'

# Slave dns, copied from
# https://github.com/rthalley/dnspython/blob/master/examples/receive_notify.py

slave_dns_addr = '192.168.56.1'
slave_dns_port = 5001 
chk_domain = 'computingforgeeks.local'


res = dns.resolver.make_resolver_at(master_dns)
answer = res.resolve(chk_domain, "SOA")
soaObj = answer[0]

notify = dns.message.make_query(chk_domain, dns.rdatatype.SOA)
notify.request_payload = soaObj
notify.set_opcode(dns.opcode.NOTIFY)
notify.flags -= dns.flags.RD


response = dns.query.udp(q=notify,
    where=slave_dns_addr,
    port=slave_dns_port,
    timeout=5)

print(f'RESPONSE: {response}')

I got traceback as:

Traceback (most recent call last):
  File "./query01.py", line 29, in <module>
    response = dns.query.udp(q=notify,
  File "/home/bino/Documents/pujo/playdns/venv/lib/python3.8/site-packages/dns/query.py", line 695, in udp
    wire = q.to_wire()
  File "/home/bino/Documents/pujo/playdns/venv/lib/python3.8/site-packages/dns/message.py", line 564, in to_wire
    if max_size < 512:
TypeError: '<' not supported between instances of 'SOA' and 'int'

Kindly please tell me how to properly send a SOA object to a DNS server.

0

There are 0 best solutions below