[Twisted-Python] Specifying the local port for a twisted.names DNS query or resolver

Anton Gyllenberg anton at iki.fi
Tue Jun 14 12:25:14 EDT 2011


I have external requirements that force me to issue DNS queries from a
specific local port range. I'm looking for a way to use the
twisted.names resolver but I need to specify a local port for a query
or set the local port range for all queries. I appreciate that the
local port randomization is there for good security reasons, but for
my application I do not care. I would be grateful for any tips or
guidelines on how to achieve this.

For some ancient Twisted version I got it working by monkey patching
twisted.names.dns.DNSDatagramProtocol.startListening() to this effect.
This ugly hack of mine does not work anymore for any recent version of
Twisted. Is there a right way to do it?

Best regards
Anton



More information about the Twisted-Python mailing list