1Net::DNS::Header(3)   User Contributed Perl Documentation  Net::DNS::Header(3)
2
3
4

NAME

6       Net::DNS::Header - DNS packet header
7

SYNOPSIS

9           use Net::DNS;
10
11           $packet = Net::DNS::Packet->new();
12           $header = $packet->header;
13

DESCRIPTION

15       "Net::DNS::Header" represents the header portion of a DNS packet.
16

METHODS

18   $packet->header
19           $packet = Net::DNS::Packet->new();
20           $header = $packet->header;
21
22       Net::DNS::Header objects emanate from the Net::DNS::Packet header()
23       method, and contain an opaque reference to the parent Packet object.
24
25       Header objects may be assigned to suitably scoped lexical variables.
26       They should never be stored in global variables or persistent data
27       structures.
28
29   string
30           print $packet->header->string;
31
32       Returns a string representation of the packet header.
33
34   print
35           $packet->header->print;
36
37       Prints the string representation of the packet header.
38
39   id
40           print "query id = ", $packet->header->id, "\n";
41           $packet->header->id(1234);
42
43       Gets or sets the query identification number.
44
45       A random value is assigned if the argument value is undefined.
46
47   opcode
48           print "query opcode = ", $packet->header->opcode, "\n";
49           $packet->header->opcode("UPDATE");
50
51       Gets or sets the query opcode (the purpose of the query).
52
53   rcode
54           print "query response code = ", $packet->header->rcode, "\n";
55           $packet->header->rcode("SERVFAIL");
56
57       Gets or sets the query response code (the status of the query).
58
59   qr
60           print "query response flag = ", $packet->header->qr, "\n";
61           $packet->header->qr(0);
62
63       Gets or sets the query response flag.
64
65   aa
66           print "response is ", $packet->header->aa ? "" : "non-", "authoritative\n";
67           $packet->header->aa(0);
68
69       Gets or sets the authoritative answer flag.
70
71   tc
72           print "packet is ", $packet->header->tc ? "" : "not ", "truncated\n";
73           $packet->header->tc(0);
74
75       Gets or sets the truncated packet flag.
76
77   rd
78           print "recursion was ", $packet->header->rd ? "" : "not ", "desired\n";
79           $packet->header->rd(0);
80
81       Gets or sets the recursion desired flag.
82
83   ra
84           print "recursion is ", $packet->header->ra ? "" : "not ", "available\n";
85           $packet->header->ra(0);
86
87       Gets or sets the recursion available flag.
88
89   z
90       Unassigned bit, should always be zero.
91
92   ad
93           print "The response has ", $packet->header->ad ? "" : "not", "been verified\n";
94
95       Relevant in DNSSEC context.
96
97       (The AD bit is only set on a response where signatures have been
98       cryptographically verified or the server is authoritative for the data
99       and is allowed to set the bit by policy.)
100
101   cd
102           print "checking was ", $packet->header->cd ? "not" : "", "desired\n";
103           $packet->header->cd(0);
104
105       Gets or sets the checking disabled flag.
106
107   qdcount, zocount
108           print "# of question records: ", $packet->header->qdcount, "\n";
109
110       Returns the number of records in the question section of the packet.
111       In dynamic update packets, this field is known as "zocount" and refers
112       to the number of RRs in the zone section.
113
114   ancount, prcount
115           print "# of answer records: ", $packet->header->ancount, "\n";
116
117       Returns the number of records in the answer section of the packet which
118       may, in the case of corrupt packets, differ from the actual number of
119       records.  In dynamic update packets, this field is known as "prcount"
120       and refers to the number of RRs in the prerequisite section.
121
122   nscount, upcount
123           print "# of authority records: ", $packet->header->nscount, "\n";
124
125       Returns the number of records in the authority section of the packet
126       which may, in the case of corrupt packets, differ from the actual
127       number of records.  In dynamic update packets, this field is known as
128       "upcount" and refers to the number of RRs in the update section.
129
130   arcount, adcount
131           print "# of additional records: ", $packet->header->arcount, "\n";
132
133       Returns the number of records in the additional section of the packet
134       which may, in the case of corrupt packets, differ from the actual
135       number of records.  In dynamic update packets, this field is known as
136       "adcount".
137

EDNS Protocol Extensions

139   do
140           print "DNSSEC_OK flag was ", $packet->header->do ? "not" : "", "set\n";
141           $packet->header->do(1);
142
143       Gets or sets the EDNS DNSSEC OK flag.
144
145   Extended rcode
146       EDNS extended rcodes are handled transparently by
147       $packet->header->rcode().
148
149   UDP packet size
150           $udp_max = $packet->edns->UDPsize;
151
152       EDNS offers a mechanism to advertise the maximum UDP packet size which
153       can be assembled by the local network stack.
154
155   edns
156           $header  = $packet->header;
157           $version = $header->edns->version;
158           @options = $header->edns->options;
159           $option  = $header->edns->option(n);
160           $udp_max = $packet->edns->UDPsize;
161
162       Auxiliary function which provides access to the EDNS protocol extension
163       OPT RR.
164
166       Copyright (c)1997 Michael Fuhr.
167
168       Portions Copyright (c)2002,2003 Chris Reinhardt.
169
170       Portions Copyright (c)2012,2022 Dick Franks.
171
172       All rights reserved.
173

LICENSE

175       Permission to use, copy, modify, and distribute this software and its
176       documentation for any purpose and without fee is hereby granted,
177       provided that the original copyright notices appear in all copies and
178       that both copyright notice and this permission notice appear in
179       supporting documentation, and that the name of the author not be used
180       in advertising or publicity pertaining to distribution of the software
181       without specific prior written permission.
182
183       THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
184       OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
185       MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
186       IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
187       CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
188       TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
189       SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
190

SEE ALSO

192       perl Net::DNS Net::DNS::Packet Net::DNS::RR::OPT RFC1035(4.1.1)
193       <https://tools.ietf.org/html/rfc1035>
194
195
196
197perl v5.36.1                      2023-06-01               Net::DNS::Header(3)
Impressum