The dns.message.QueryMessage Class

The dns.message.QueryMessage class is used for ordinary DNS query messages.

class dns.message.QueryMessage(id: int | None = None)[source]
canonical_name() Name[source]

Return the canonical name of the first name in the question section.

Raises dns.message.NotQueryResponse if the message is not a response.

Raises dns.message.ChainTooLong if the CNAME chain is too long.

Raises dns.message.AnswerForNXDOMAIN if the rcode is NXDOMAIN but an answer was found.

Raises dns.exception.FormError if the question count is not 1.

resolve_chaining() ChainingResult[source]

Follow the CNAME chain in the response to determine the answer RRset.

Raises dns.message.NotQueryResponse if the message is not a response.

Raises dns.message.ChainTooLong if the CNAME chain is too long.

Raises dns.message.AnswerForNXDOMAIN if the rcode is NXDOMAIN but an answer was found.

Raises dns.exception.FormError if the question count is not 1.

Returns a ChainingResult object.

The dns.message.ChainingResult Class

Objects of the dns.message.ChainingResult class are returned by the dns.message.QueryMessage.resolve_chaining() method.

class dns.message.ChainingResult(canonical_name: Name, answer: RRset | None, minimum_ttl: int, cnames: List[RRset])[source]

The result of a call to dns.message.QueryMessage.resolve_chaining().

The answer attribute is the answer RRSet, or None if it doesn’t exist.

The canonical_name attribute is the canonical name after all chaining has been applied (this is the same name as rrset.name in cases where rrset is not None).

The minimum_ttl attribute is the minimum TTL, i.e. the TTL to use if caching the data. It is the smallest of all the CNAME TTLs and either the answer TTL if it exists or the SOA TTL and SOA minimum values for negative answers.

The cnames attribute is a list of all the CNAME RRSets followed to get to the canonical name.