0
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.

retr0
  • 1
  • What is the problem you are having? – Michael Hampton Mar 14 '21 at 19:47
  • @Michael Hampton, Problems: 1. I cannot alter the DNS response using the script I have shown 2. I don't know how to deploy this on port 53 on a server like digital ocean without messing up something (since I use port 53 which I suppose other apps use apart from mine) – retr0 Mar 14 '21 at 19:51
  • We can't help with debugging your Python code. You can visit [so] for that. As for running it on port 53 on your server, what are you already running on port 53 on your server? – Michael Hampton Mar 14 '21 at 19:59
  • The script to filter requests and respond in a personalized way when trying to resolve a certain domain. I run the script on port 53 of my vps for that purpose. – retr0 Mar 14 '21 at 20:03
  • You can't have two different programs listening on the same port at the same time! – Michael Hampton Mar 14 '21 at 20:16

0 Answers0