DNS toolkit for Python supporting almost all record types with high-level and low-level DNS operations
85
Build a client that issues DNS queries to a single configurable nameserver using multiple transports (UDP, TCP, TLS, HTTPS), falling back from UDP to TCP when needed while keeping results consistent across protocols.
example.com using UDP and returns all IPv4 addresses sorted lexicographically. @testexample.com using DNS-over-TLS against the configured endpoint and returns addresses including 93.184.216.34. @testexample.com using DNS-over-HTTPS (GET) against the configured endpoint and returns addresses including 93.184.216.34. @test@generates
class TransportClient:
def __init__(self, nameserver: str, udp_timeout: float = 2.0, tcp_timeout: float = 4.0, tls_port: int = 853, https_url: str | None = None):
"""Create a client bound to a target resolver supporting UDP/TCP/TLS and an optional HTTPS endpoint."""
def query(self, qname: str, rdtype: str = "A", transport: str = "udp") -> list[str]:
"""Execute a DNS query over the chosen transport ('udp', 'tcp', 'tls', 'https') and return the RDATA text values in order of arrival."""
def query_with_fallback(self, qname: str, rdtype: str = "A", udp_payload_size: int = 512) -> list[str]:
"""Perform a UDP query (respecting the payload size), and on truncation or timeout, retry over TCP automatically before returning results."""Python DNS toolkit for building, sending, and parsing DNS messages across multiple transports.
Install with Tessl CLI
npx tessl i tessl/pypi-dnspythondocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10