Queries

DNS queries are represented by Query objects, which hold a name to look up, a query type and a query class.

class Query(name, q_type, q_class)
Represents a DNS query.
Parameters:
  • name (ipaddress.IPv6Address) – The name to query.
  • q_type (int) – The RR type you’re querying for.
  • q_class (int) – The RR class you’re querying for.

name may be specified as a Python string (in which case, IDNA is applied if necessary); or as a Python bytes object (in which case the bytes are used literally, subject to the usual rules on DNS labels); or an IP address using the ipaddress module’s IPv4Address or IPv6Address objects, in which case the address will be automatically turned into the appropriate form for a reverse lookup.

There are constants for most query types in the asyncdns module, e.g. asyncdns.A, asyncdns.AAAA and so on, but you can use the numeric value if required. Possible values are:

Constant Value Meaning
A 1 IPv4 address
NS 2 Nameserver
MD 3 Mail destination (obsolete)
MF 4 Mail forwarder (obsolete)
CNAME 5 Canonical name record - an alias
SOA 6 Start Of Authority
MB 7 Mailbox domain name (obsolete)
MG 8 Mail group member (obsolete)
MR 9 Mail rename (obsolete)
NUL 10 Null
WKS 11 Well Known Service description (obsolete)
PTR 12 Pointer - for inverse queries
HINFO 13 Host information (obsolete)
MINFO 14 Mailbox or list information (obsolete)
MX 15 Mail eXchanger
TXT 16 Free format text
RP 17 Responsible person
AFSDB 18 AFS database record
X25 19 X.121 address, as used on X.25 networks
ISDN 20 ISDN address
RT 21 Route record, for X.25 or ISDN
NSAP 22 OSI NSAP address
NSAPPTR 23 NSAP Pointer - for inverse queries
SIG 24 (Old) DNSSEC signature (obsolete)
KEY 25 (Old) DNSSEC key (obsolete)
PX 26 X.400 mail mapping information (obsolete)
GPOS 27 Geographical location (obsolete)
AAAA 28 IPv6 address
LOC 29 Geographical location
NXT 30 (Old) DNSSEC Next record (obsolete)
EID 31 Nimrod Endpoint Identifier (obsolete)
NIMLOC 32 Nimrod Locator (obsolete)
SRV 33 Service locator
ATMA 34 ATM address
NAPTR 35 Naming Authority Pointer - regex rewriting
KX 36 Key exchanger record
CERT 37 Certificate record
A6 38 Intended to replace AAAA (obsolete)
DNAME 39 Alias for a name and all subnames
SINK 40 Kitchen sink (joke, obsolete)
OPT 41 EDNS option (PSEUDO-RR)
APL 42 Address Prefix List
DS 43 Delegation Signer record
SSHFP 44 SSH public key fingerprint
IPSECKEY 45 IPsec key
RRSIG 46 DNSSEC signature
NSEC 47 Next Secure record - to prove non-existence
DNSKEY 48 DNSSEC key record
DHCID 49 DHCP identifier
NSEC3 50 Next Secure record (v3)
NSEC3PARAM 51 NSEC3 parameter record
TLSA 52 TLSA cetificate association
HIP 55 Host Identity Protocol record
CDS 59 Child DS record
CDNSKEY 60 Child DNSKEY
OPENPGPKEY 61 OpenPGP public key
SPF 99 SPF record (obsolete)
UINFO 100 Reserved
UID 101 Reserved
GID 102 Reserved
UNSPEC 103 Reserved
TKEY 249 Transaction key
TSIG 250 Transaction signature
IXFR 251 Incremental zone transfer (PSEUDO-RR)
AXFR 252 Authoritative zone transfers (PSEUDO-RR)
MAILB 253 Used to get MB/MG/MR/MINFO records (obsolete)
MAILA 254 Used to retrieve MD or MF records (obsolete)
ANY 255 Return all record types (PSEUDO-RR)
URI 256 Maps a hostname to a URI
CAA 257 Certificate Authority Authorization
TA 32768 DNSSEC Trust Authorities
DLV 32769 DNSSEC Lookaside Validation record

The query class will almost always be asyncdns.IN. Possible values are:

Constant Value Meaning
IN 1 Internet
CH 3 Chaos
HS 4 Hesiod
NONE 254  
ANY 255  
__lt__(other)
__eq__(other)
__ne__(other)
__gt__(other)
__ge__(other)
__le__(other)

Query provides comparison and ordering operators.

__hash__()

Query is also hashable, so it can be used as a key in a dict or set.

__repr__()

Returns a debug representation.