or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

dns-constants.mddns-exceptions.mddns-messages.mddns-names.mddns-queries.mddns-records.mddns-resolution.mddns-updates.mddns-utilities.mddns-zones.mddnssec.mdindex.mdtsig.md

dns-constants.mddocs/

0

# DNS Constants and Enumerations

1

2

Comprehensive constants and enumerations for DNS operations including record types, classes, flags, opcodes, and response codes. These constants are essential for working with DNS records and messages.

3

4

## Capabilities

5

6

### DNS Record Types

7

8

Constants defining all supported DNS record types. Used throughout dnspython for specifying record types in queries, messages, and data structures.

9

10

```python { .api }

11

# Core record types

12

NONE = 0

13

A = 1

14

NS = 2

15

MD = 3

16

MF = 4

17

CNAME = 5

18

SOA = 6

19

MB = 7

20

MG = 8

21

MR = 9

22

NULL = 10

23

WKS = 11

24

PTR = 12

25

HINFO = 13

26

MINFO = 14

27

MX = 15

28

TXT = 16

29

RP = 17

30

AFSDB = 18

31

X25 = 19

32

ISDN = 20

33

RT = 21

34

NSAP = 22

35

NSAP_PTR = 23

36

SIG = 24

37

KEY = 25

38

PX = 26

39

GPOS = 27

40

AAAA = 28

41

LOC = 29

42

NXT = 30

43

EID = 31

44

NIMLOC = 32

45

SRV = 33

46

ATMA = 34

47

NAPTR = 35

48

KX = 36

49

CERT = 37

50

A6 = 38

51

DNAME = 39

52

SINK = 40

53

OPT = 41

54

APL = 42

55

DS = 43

56

SSHFP = 44

57

IPSECKEY = 45

58

RRSIG = 46

59

NSEC = 47

60

DNSKEY = 48

61

DHCID = 49

62

NSEC3 = 50

63

NSEC3PARAM = 51

64

TLSA = 52

65

HIP = 55

66

NINFO = 56

67

RKEY = 57

68

TALINK = 58

69

CDS = 59

70

CDNSKEY = 60

71

OPENPGPKEY = 61

72

CSYNC = 62

73

SPF = 99

74

UINFO = 100

75

UID = 101

76

GID = 102

77

UNSPEC = 103

78

NID = 104

79

L32 = 105

80

L64 = 106

81

LP = 107

82

EUI48 = 108

83

EUI64 = 109

84

TKEY = 249

85

TSIG = 250

86

IXFR = 251

87

AXFR = 252

88

MAILB = 253

89

MAILA = 254

90

ANY = 255

91

URI = 256

92

CAA = 257

93

AVC = 258

94

DOA = 259

95

AMTRELAY = 260

96

TA = 32768

97

DLV = 32769

98

99

def from_text(text: str) -> int

100

def to_text(value: int) -> str

101

def is_metatype(rdtype: int) -> bool

102

def is_singleton(rdtype: int) -> bool

103

```

104

105

### DNS Record Classes

106

107

Constants defining DNS record classes for different network types and operational contexts.

108

109

```python { .api }

110

RESERVED0 = 0

111

IN = 1 # Internet

112

CH = 3 # Chaos

113

HS = 4 # Hesiod

114

NONE = 254 # None (used in dynamic updates)

115

ANY = 255 # Any class (query wildcard)

116

117

def from_text(text: str) -> int

118

def to_text(value: int) -> str

119

def is_metaclass(rdclass: int) -> bool

120

```

121

122

### DNS Message Flags

123

124

Bit flag constants for DNS message headers controlling query behavior and response characteristics.

125

126

```python { .api }

127

# Standard DNS header flags

128

QR = 0x8000 # Query Response (0=query, 1=response)

129

AA = 0x0400 # Authoritative Answer

130

TC = 0x0200 # Truncated Response

131

RD = 0x0100 # Recursion Desired

132

RA = 0x0080 # Recursion Available

133

Z = 0x0040 # Reserved (must be zero)

134

AD = 0x0020 # Authentic Data (DNSSEC)

135

CD = 0x0010 # Checking Disabled (DNSSEC)

136

137

def from_text(text: str) -> int

138

def to_text(value: int) -> str

139

```

140

141

### DNS Opcodes

142

143

Operation codes defining the type of DNS operation being performed in a message.

144

145

```python { .api }

146

QUERY = 0 # Standard query

147

IQUERY = 1 # Inverse query (deprecated)

148

STATUS = 2 # Server status request

149

NOTIFY = 4 # Zone change notification

150

UPDATE = 5 # Dynamic DNS update

151

152

def from_text(text: str) -> int

153

def to_text(value: int) -> str

154

```

155

156

### DNS Response Codes

157

158

Response codes indicating the result status of DNS operations and queries.

159

160

```python { .api }

161

NOERROR = 0 # No error

162

FORMERR = 1 # Format error

163

SERVFAIL = 2 # Server failure

164

NXDOMAIN = 3 # Non-existent domain

165

NOTIMP = 4 # Not implemented

166

REFUSED = 5 # Query refused

167

YXDOMAIN = 6 # Name exists when it should not

168

YXRRSET = 7 # RR set exists when it should not

169

NXRRSET = 8 # RR set that should exist does not

170

NOTAUTH = 9 # Server not authoritative for zone

171

NOTZONE = 10 # Name not contained in zone

172

BADVERS = 16 # Bad OPT version

173

BADSIG = 16 # TSIG signature failure

174

BADKEY = 17 # Key not recognized

175

BADTIME = 18 # Signature out of time window

176

BADMODE = 19 # Bad TKEY mode

177

BADNAME = 20 # Duplicate key name

178

BADALG = 21 # Algorithm not supported

179

BADTRUNC = 22 # Bad truncation

180

181

def from_text(text: str) -> int

182

def to_text(value: int) -> str

183

```

184

185

## Usage Examples

186

187

### Working with Record Types

188

189

```python

190

import dns.rdatatype

191

192

# Convert between text and numeric forms

193

a_type = dns.rdatatype.from_text('A') # Returns 1

194

type_name = dns.rdatatype.to_text(1) # Returns 'A'

195

196

# Check record type properties

197

is_meta = dns.rdatatype.is_metatype(dns.rdatatype.ANY) # True

198

is_single = dns.rdatatype.is_singleton(dns.rdatatype.SOA) # True

199

200

# Use constants directly

201

query_type = dns.rdatatype.AAAA # IPv6 address record

202

mx_type = dns.rdatatype.MX # Mail exchange record

203

```

204

205

### Working with Message Flags

206

207

```python

208

import dns.flags

209

210

# Combine flags for query messages

211

flags = dns.flags.RD | dns.flags.AD # Recursion desired + authentic data

212

213

# Check individual flags

214

if response_flags & dns.flags.AA:

215

print("Response is authoritative")

216

217

if response_flags & dns.flags.TC:

218

print("Response was truncated, retry with TCP")

219

```

220

221

### Working with Response Codes

222

223

```python

224

import dns.rcode

225

226

# Check response status

227

if response.rcode() == dns.rcode.NOERROR:

228

print("Query successful")

229

elif response.rcode() == dns.rcode.NXDOMAIN:

230

print("Domain does not exist")

231

elif response.rcode() == dns.rcode.SERVFAIL:

232

print("Server failure")

233

234

# Convert response codes to text

235

error_text = dns.rcode.to_text(response.rcode())

236

```

237

238

## Types

239

240

```python { .api }

241

# All constants modules provide these utility functions

242

def from_text(text: str) -> int:

243

"""Convert text name to numeric value."""

244

245

def to_text(value: int) -> str:

246

"""Convert numeric value to text name."""

247

248

# Record type specific functions

249

def is_metatype(rdtype: int) -> bool:

250

"""Check if record type is a metatype (like ANY)."""

251

252

def is_singleton(rdtype: int) -> bool:

253

"""Check if only one record of this type can exist per name."""

254

255

# Record class specific functions

256

def is_metaclass(rdclass: int) -> bool:

257

"""Check if record class is a metaclass (like ANY)."""

258

```