Net::DNS::Header(3)

🌸 NAME 🌸

okay so bestie, welcome to Net::DNS::Header(3) from the User Contributed Perl Documentation crowd πŸ’– β€” this is the manual page for Net::DNS::Header, aka the DNS packet header. It's literally the header portion of a DNS packet, and yes, it's giving main-character energy for the whole packet. ✨

✨ SYNOPSIS ✨

use Net::DNS;

$packet = Net::DNS::Packet->new();
$header = $packet->header;

πŸ¦‹ DESCRIPTION πŸ¦‹

Net::DNS::Header represents the header portion of a DNS packet. That's the whole vibe: header business, no extra packet drama. πŸ’…

πŸ’… METHODS πŸ’…

πŸŽ€ $packet->header πŸŽ€

$packet = Net::DNS::Packet->new();
$header = $packet->header;

Net::DNS::Header objects emanate from the Net::DNS::Packet header() method, and contain an opaque reference to the parent Packet object.

Header objects may be assigned to suitably scoped lexical variables. They should never be stored in global variables or persistent data structures. Like, keep them lexical and local, bestie β€” no global-variable chaos, fr fr. 🫢

✨ string ✨

print $packet->header->string;

Returns a string representation of the packet header. Cute, printable, done. πŸŽ€

πŸ’– print πŸ’–

$packet->header->print;

Prints the string representation of the packet header.

πŸ”₯ id πŸ”₯

print "query id = ", $packet->header->id, "\n";
$packet->header->id(1234);

Gets or sets the query identification number.

πŸ¦‹ opcode πŸ¦‹

print "query opcode = ", $packet->header->opcode, "\n";
$packet->header->opcode("UPDATE");

Gets or sets the query opcode (the purpose of the query).

🌸 rcode 🌸

print "query response code = ", $packet->header->rcode, "\n";
$packet->header->rcode("SERVFAIL");

Gets or sets the query response code (the status of the query).

⭐ qr ⭐

print "query response flag = ", $packet->header->qr, "\n";
$packet->header->qr(0);

Gets or sets the query response flag.

πŸ‘‘ aa πŸ‘‘

print "response is ", $packet->header->aa ? "" : "non-", "authoritative\n";
$packet->header->aa(0);

Gets or sets the authoritative answer flag.

🧚 tc 🧚

print "packet is ", $packet->header->tc ? "" : "not ", "truncated\n";
$packet->header->tc(0);

Gets or sets the truncated packet flag.

πŸ“ rd πŸ“

print "recursion was ", $packet->header->rd ? "" : "not ", "desired\n";
$packet->header->rd(0);

Gets or sets the recursion desired flag.

🌈 ra 🌈

print "recursion is ", $packet->header->ra ? "" : "not ", "available\n";
$packet->header->ra(0);

Gets or sets the recursion available flag.

πŸ’€ z πŸ’€

Unassigned bit, should always be zero. That's it. No notes. πŸ’€

print "The response has ", $packet->header->ad ? "" : "not", "been verified\n";

Relevant in DNSSEC context.

(The AD bit is only set on a response where signatures have been cryptographically verified or the server is authoritative for the data and is allowed to set the bit by policy.)

πŸ’œ cd πŸ’œ

print "checking was ", $packet->header->cd ? "not" : "", "desired\n";
$packet->header->cd(0);

Gets or sets the checking disabled flag.

πŸŽ€ qdcount, zocount πŸŽ€

print "# of question records: ", $packet->header->qdcount, "\n";

Returns the number of records in the question section of the packet. In dynamic update packets, this field is known as zocount and refers to the number of RRs in the zone section.

πŸ¦‹ ancount, prcount πŸ¦‹

print "# of answer records: ", $packet->header->ancount, "\n";

Returns the number of records in the answer section of the packet which may, in the case of corrupt packets, differ from the actual number of records. In dynamic update packets, this field is known as prcount and refers to the number of RRs in the prerequisite section.

🌸 nscount, upcount 🌸

print "# of authority records: ", $packet->header->nscount, "\n";

Returns the number of records in the authority section of the packet which may, in the case of corrupt packets, differ from the actual number of records. In dynamic update packets, this field is known as upcount and refers to the number of RRs in the update section.

⭐ arcount, adcount ⭐

print "# of additional records: ", $packet->header->arcount, "\n";

Returns the number of records in the additional section of the packet which may, in the case of corrupt packets, differ from the actual number of records. In dynamic update packets, this field is known as adcount.

🌈 EDNS Protocol Extensions 🌈

🧚 do, co, de 🧚

print "DNSSEC_OK flag was ", $packet->header->do ? "not" : "", "set\n";
$packet->header->do(1);

Gets or sets the named EDNS flag.

πŸ”₯ Extended rcode πŸ”₯

EDNS extended rcodes are handled transparently by $packet->header->rcode().

πŸŽ€ UDP packet size πŸŽ€

$udp_max = $packet->edns->UDPsize;

EDNS offers a mechanism to advertise the maximum UDP packet size which can be assembled by the local network stack.

🫢 edns 🫢

$header  = $packet->header;
$version = $header->edns->version;
@options = $header->edns->options;
$option  = $header->edns->option(n);
$udp_max = $packet->edns->UDPsize;

Auxiliary function which provides access to the EDNS protocol extension OPT RR.

Copyright (c)1997 Michael Fuhr.

Portions Copyright (c)2002,2003 Chris Reinhardt.

Portions Copyright (c)2012,2022 Dick Franks.

All rights reserved.

πŸ“œ LICENSE πŸ“œ

Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the original copyright notices appear in all copies and that both copyright notice and this permission notice appear in supporting documentation, and that the name of the author not be used in advertising or publicity pertaining to distribution of the software without specific prior written permission.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

πŸ”Ž SEE ALSO πŸ”Ž


mwah πŸ’‹ this Net::DNS::Header(3) page is from perl v5.42.0, dated 2026-09-02 β€” bye bestie, go read those DNS headers responsibly! πŸŒˆβœ¨πŸ’–

πŸ“¦ where this page comes from