Rdata classes and types

Sets of typed data can be associated with a given name. A single typed datum is called an rdata. The type of an rdata is specified by its rdataclass and rdatatype. The class is almost always IN, the Internet class, and may often be omitted in the dnspython APIs.

The dns.rdataclass module provides constants for each defined rdata class, as well as some helpful functions. The dns.rdatatype module does the same for rdata types. Examples of the constants are:

dns.rdataclass.IN
dns.rdatatype.AAAA

DNS Rdata Classes.

class dns.rdataclass.RdataClass[source]

DNS Rdata Class

exception dns.rdataclass.UnknownRdataclass(*args, **kwargs)[source]

A DNS class is unknown.

dns.rdataclass.from_text(text)[source]

Convert text into a DNS rdata class value.

The input text can be a defined DNS RR class mnemonic or instance of the DNS generic class syntax.

For example, “IN” and “CLASS1” will both result in a value of 1.

Raises dns.rdatatype.UnknownRdataclass if the class is unknown.

Raises ValueError if the rdata class value is not >= 0 and <= 65535.

Returns an int.

dns.rdataclass.is_metaclass(rdclass)[source]

True if the specified class is a metaclass.

The currently defined metaclasses are ANY and NONE.

rdclass is an int.

dns.rdataclass.to_text(value)[source]

Convert a DNS rdata class value to text.

If the value has a known mnemonic, it will be used, otherwise the DNS generic class syntax will be used.

Raises ValueError if the rdata class value is not >= 0 and <= 65535.

Returns a str.

DNS Rdata Types.

class dns.rdatatype.RdataType[source]

DNS Rdata Type

exception dns.rdatatype.UnknownRdatatype(*args, **kwargs)[source]

DNS resource record type is unknown.

dns.rdatatype.from_text(text)[source]

Convert text into a DNS rdata type value.

The input text can be a defined DNS RR type mnemonic or instance of the DNS generic type syntax.

For example, “NS” and “TYPE2” will both result in a value of 2.

Raises dns.rdatatype.UnknownRdatatype if the type is unknown.

Raises ValueError if the rdata type value is not >= 0 and <= 65535.

Returns an int.

dns.rdatatype.is_metatype(rdtype)[source]

True if the specified type is a metatype.

rdtype is an int.

The currently defined metatypes are TKEY, TSIG, IXFR, AXFR, MAILA, MAILB, ANY, and OPT.

Returns a bool.

dns.rdatatype.is_singleton(rdtype)[source]

Is the specified type a singleton type?

Singleton types can only have a single rdata in an rdataset, or a single RR in an RRset.

The currently defined singleton types are CNAME, DNAME, NSEC, NXT, and SOA.

rdtype is an int.

Returns a bool.

dns.rdatatype.register_type(rdtype, rdtype_text, is_singleton=False)[source]

Dynamically register an rdatatype.

rdtype, an int, the rdatatype to register.

rdtype_text, a str, the textual form of the rdatatype.

is_singleton, a bool, indicating if the type is a singleton (i.e. RRsets of the type can have only one member.)

dns.rdatatype.to_text(value)[source]

Convert a DNS rdata type value to text.

If the value has a known mnemonic, it will be used, otherwise the DNS generic type syntax will be used.

Raises ValueError if the rdata type value is not >= 0 and <= 65535.

Returns a str.