Message Rcodes

A DNS Rcode describes the result of a DNS request. If EDNS is not in use, then the rcode is encoded solely in the DNS header. If EDNS is in use, then the rcode is encoded using bits form both the header and the EDNS OPT RR.

class dns.rcode.Rcode(value)[source]
BADALG = 21

Algorithm not supported.

BADCOOKIE = 23

Bad/missing Server Cookie

BADKEY = 17

Key not recognized.

BADMODE = 19

Bad TKEY Mode.

BADNAME = 20

Duplicate key name.

BADSIG = 16

TSIG Signature Failure

BADTIME = 18

Signature out of time window.

BADTRUNC = 22

Bad Truncation

BADVERS = 16

Bad EDNS version.

DSOTYPENI = 11

DSO-TYPE Not Implemented

FORMERR = 1

Format error

NOERROR = 0

No error

NOTAUTH = 9

Not authoritative.

NOTIMP = 4

Not implemented

NOTZONE = 10

Name not in zone.

NXDOMAIN = 3

Name does not exist (“Name Error” in RFC 1025 terminology).

NXRRSET = 8

RRset does not exist.

REFUSED = 5

Refused

SERVFAIL = 2

Server failure

YXDOMAIN = 6

Name exists.

YXRRSET = 7

RRset exists.

dns.rcode.NOERROR = Rcode.NOERROR
dns.rcode.FORMERR = Rcode.FORMERR
dns.rcode.SERVFAIL = Rcode.SERVFAIL
dns.rcode.NXDOMAIN = Rcode.NXDOMAIN
dns.rcode.NOTIMP = Rcode.NOTIMP
dns.rcode.REFUSED = Rcode.REFUSED
dns.rcode.YXDOMAIN = Rcode.YXDOMAIN
dns.rcode.YXRRSET = Rcode.YXRRSET
dns.rcode.NXRRSET = Rcode.NXRRSET
dns.rcode.NOTAUTH = Rcode.NOTAUTH
dns.rcode.NOTZONE = Rcode.NOTZONE
dns.rcode.BADVERS = Rcode.BADVERS
dns.rcode.from_text(text: str) Rcode[source]

Convert text into an rcode.

Parameters:

text (str) – The textual rcode or an integer in textual form.

Raises:

dns.rcode.UnknownRcode – If the rcode mnemonic is unknown.

Return type:

dns.rcode.Rcode

dns.rcode.to_text(value: Rcode, tsig: bool = False) str[source]

Convert rcode into text.

Parameters:

value (dns.rcode.Rcode) – The rcode.

Raises:

ValueError – If the rcode is < 0 or > 4095.

Return type:

str

dns.rcode.from_flags(flags: int, ednsflags: int) Rcode[source]

Return the rcode value encoded by flags and ednsflags.

Parameters:
  • flags (int) – The DNS flags field.

  • ednsflags (int) – The EDNS flags field.

Raises:

ValueError – If the rcode is < 0 or > 4095.

Return type:

dns.rcode.Rcode

dns.rcode.to_flags(value: Rcode) tuple[int, int][source]

Return a (flags, ednsflags) tuple which encodes the rcode.

Parameters:

value (dns.rcode.Rcode) – The rcode.

Raises:

ValueError – If the rcode is < 0 or > 4095.

Return type:

tuple[int, int]