Net::DNS::RR::OPT(3)
π Net::DNS::RR::OPT π
okay bestie, gather round π«Ά this is the Net::DNS::RR::OPT page from the User Contributed Perl Documentation β it's the DNS OPT resource record, and honestly it's lowkey the main character of EDNS. let's get into it β¨
β¨ NAME β¨
Net::DNS::RR::OPT β the DNS OPT resource record π
πΈ SYNOPSIS πΈ
use Net::DNS;
my $packet = Net::DNS::Packet->new( ... );
$packet->header->do(1); # extended header flag
$packet->edns->UDPsize(1232); # UDP payload size
$packet->edns->option( 'NSID' => {'OPTION-DATA' => 'rawbytes'} );
$packet->edns->option( 'DAU' => [8, 10, 13, 14, 15, 16] );
$packet->edns->option( 'TCP-KEEPALIVE' => 200 );
$packet->edns->option( 'EXTENDED-ERROR' => {'INFO-CODE' => 123} );
$packet->edns->option( '65023' => {'BASE16' => '076578616d706c6500'} );
$packet->edns->print;
;; { "EDNS-VERSION": 0,
;; "FLAGS": 32768,
;; "RCODE": 0,
;; "UDPSIZE": 1232,
;; "OPTIONS": [
;; {"NSID": "7261776279746573"},
;; {"DAU": [ 8, 10, 13, 14, 15, 16 ]},
;; {"TCP-KEEPALIVE": {"TIMEOUT": 200}},
;; {"EXTENDED-ERROR": {"INFO-CODE": 123, "EXTRA-TEXT": ""}},
;; {"65023": {"BASE16": "076578616d706c6500"}} ]
;; }
like, look at that print output. it's giving structured JSON realness and I am obsessed π
π¦ DESCRIPTION π¦
it's the EDNS OPT pseudo resource record, periodt.
here's the important bit, no cap: the OPT record supports EDNS protocol extensions and is not intended to be created, accessed or modified directly by user applications. so like... hands off, bestie π
all EDNS features get performed indirectly, through operations on the objects that come back from the $packet->header and $packet->edns creator methods. the underlying mechanisms are, or should be, entirely hidden from you. iykyk β you're not supposed to peek behind the curtain π
β METHODS β
the available methods are the ones inherited from the base class, plus the type-specific methods defined in this package β¨
β οΈ real talk: use of undocumented package features or direct access to internal data structures is discouraged and could result in program termination or other unpredictable behaviour. so don't do it, bestie, it's not worth the chaos π
π version
$version = $packet->edns->version;
the version of EDNS supported by this OPT record. that's it, that's the whole vibe.
π UDPsize
$size = $packet->edns->UDPsize;
$packet->edns->UDPsize($size);
UDPsize() advertises the maximum size (in octets) of UDP packet that can be reassembled in the network stack of the originating host. lowkey a flex, but a polite one π
π rcode
$extended_rcode = $packet->header->rcode;
the 12 bit extended RCODE, bestie. the most significant 8 bits come from the OPT record, and the least significant 4 bits live in the packet header. split custody, iconic behavior π
π flags
$do = $packet->header->do;
$packet->header->do(1);
$edns_flags = $packet->edns->flags;
a 16 bit field containing the EDNS extended header flags π₯
π options
my @options = $packet->edns->options;
when you call options() in a list context, it returns a list of option codes found in the OPT record. cute, tidy, done π
π option
my $octets = $packet->edns->option('COOKIE');
my $base16 = unpack 'H*', $octets;
when you call option() in a scalar context with a single argument, it returns the value of the specified option as an uninterpreted octet string. and if the option isn't there? it returns undef. we love a graceful letdown π
$packet->edns->option( 'COOKIE' => {'OPTION-DATA' => $octets} );
$packet->edns->option( '10' => {'BASE16' => $base16} );
an option can be added or replaced by providing the (name,value) pair. and if the value is undefined, the option gets deleted. poof, gone π§
my ($structure) = $packet->edns->option("DAU");
my $array = $$structure{"DAU"};
my @algorithms = @$array;
my ($structure) = $packet->edns->option(15);
my $table = $$structure{"EXTENDED-ERROR"};
my $info_code = $$table{'INFO-CODE'};
my $extra_text = $$table{'EXTRA-TEXT'};
when you call option() in a list context with a single argument, it hands you back a structured representation of the specified option. it's giving depth, it's giving layers π
similar forms of array or hash syntax can be used to construct the option value too π
$packet->edns->option( 'DAU' => [8, 10, 13, 14, 15, 16] );
$packet->edns->option( 'EXTENDED-ERROR' => {
'INFO-CODE' => 123,
'EXTRA-TEXT' => ""
} );
π COPYRIGHT π
Copyright (c)2001,2002 RIPE NCC. Author Olaf M. Kolkman.
Portions Copyright (c)2012,2017-2026 Dick Franks.
All rights reserved.
Package template (c)2009,2012 O.M.Kolkman and R.W.Franks.
π 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. all the receipts, all above board π«Ά
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.
(that's the legal equivalent of "no promises bestie, you break it you bought it" π)
π SEE ALSO π
perl Net::DNS Net::DNS::RR RFC6891 <https://iana.org/go/rfc6891> RFC3225 <https://iana.org/go/rfc3225>
go read the RFCs, they're literally the lore ππ
and that's the page, babes πΈ β brought to you by perl v5.42.0, dated 2026-09-02, paged as Net::DNS::RR::OPT(3). slay, bye ππ
π¦ where this page comes from
- opensuse-leap 16.0: perl-Net-DNS 1.570.0-bp160.1.1 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms