Subject: | Unable to return edns record (Net::DNS::RR::OPT) in additional section |
In Net/DNS/Packet.pm, it forbids all Net::DNS::RR::OPT objects in additional section:
my $edns = $self->edns; # EDNS support
my @addl = grep !$_->isa('Net::DNS::RR::OPT'), @{$self->{additional}};
unshift( @addl, $edns ) if $edns->_specified;
$self->{additional} = \@addl;
According to RFC 6891:
If an OPT record is present in a received request, compliant responders MUST include an OPT record in their respective responses.
When I tried to implement edns-client-subnet, spec requires to include OPT RR, like this ("dig www.google.com @8.8.8.8 +client=140.112.2.0/24" and "tshark -V" to sniff return packets):
Additional records
<Root>: type OPT
Name: <Root>
Type: OPT (EDNS0 option)
UDP payload size: 512
Higher bits in extended RCODE: 0x0
EDNS0 version: 0
Z: 0x0
Data length: 11
Option: Unknown (8)
Option Code: Unknown (8)
Option Length: 7
Option Data: 000118188c7002