from dnslib.server import *
class TestResolver:
def resolve(self,request,handler):
reply = request.reply()
reply.add_answer(*RR.fromZone("abc.def. 60 A 1.2.3.4"))
return reply
resolver = TestResolver()
logger = DNSLogger(prefix=False)
server = DNSServer(resolver,port=8053,address="localhost",logger=logger,tcp=True)
server.start_thread()
q = DNSRecord.question("abc.def")
a = q.send("localhost",8053,tcp=True)
print(DNSRecord.parse(a))
server.stop()
I am analyzing a small example script from a ddns server. The problem here is that I want it to return a specific ip but for a specific query. On the other hand, I can't get the change to be carried out correctly, I put it on port 53 (I don't know if that is affecting the normal behavior of the system when putting the script on port 53) but I need that this listens to all the resolutions that come to it from my domain, and solves them as indicated in the script. (I have a vps in digital ocean where I hope to put this script so that said vps works as a ddns server.
Any ideas? Thanks.