Subject: | UPDATE add overrides ttl of zero |
The cannonical:
$update = Net::DNS::Update->new( $zone, 'IN' );
$update->push( update => rr_add( "$host $ttl $type $address" ) );
$reply = $res->send( $update );
results in a ttl of 86400 when $ttl is explicitly specified as zero.
This is not intuitive.
The code that does this appears to be in Net::DNS.pm
sub rr_add {
my $rr = new Net::DNS::RR(shift);
$rr->{ttl} ||= 86400;
return $rr;
}
I can't think of a good reason for this. 0 may not be a wise choice for TTL (it's supposed to mean 'don't cache this'), but forcing it to a day is also not wise.
The caller said "don't cache", and Net::DNS says "OK, I'll cache for a day".
I'd prefer to see:
$rr->{ttl} = 86400 unless( defined $rr->{ttl} );
or something along those lines. Is there some history behind the current code that explains why it's forcing a day?
BTW, there are use cases for 0 - e.g. when a wireless hotspot gives out false answers to get 'google.com' to go to their login page.
Or when one is debugging, er, CAA and really, really doesn't want corrupt records cached :-)