Re: Responding with a subset of an rrset

2018-04-17 Thread speijnik
Hi Tony,

On Thursday, April 12, 2018 at 2:44:08 PM UTC+2, Tony Finch wrote:
> Sounds like a job for dnsdist - https://dnsdist.org/rules-actions.html

Thanks for the pointer. dnsdist sounds quite nice, I'd still need to have this 
functionality directly in bind though.

In the meantime I have found a possible approach though, (ab-)using 
dnsrps/librpz which came with Bind 9.12 for this purpose.

Best,

Stephan
___
Please visit https://lists.isc.org/mailman/listinfo/bind-users to unsubscribe 
from this list

bind-users mailing list
bind-users@lists.isc.org
https://lists.isc.org/mailman/listinfo/bind-users


Re: Responding with a subset of an rrset

2018-04-12 Thread Tony Finch
speijnik  wrote:
>
> I'm currently looking for a way of making bind9 respond with a subset of an
> rrset. I'd need a way of returning a random pick of a limited number of
> records from a given rrset.

Sounds like a job for dnsdist - https://dnsdist.org/rules-actions.html

Tony.
-- 
f.anthony.n.finchhttp://dotat.at/
Fisher: East 6 to gale 8, occasionally severe gale 9 later. Moderate or rough,
becoming very rough in northwest. Showers later. Good.
___
Please visit https://lists.isc.org/mailman/listinfo/bind-users to unsubscribe 
from this list

bind-users mailing list
bind-users@lists.isc.org
https://lists.isc.org/mailman/listinfo/bind-users


Re: Responding with a subset of an rrset

2018-04-12 Thread speijnik
Hi Ged,

On Wednesday, April 11, 2018 at 11:25:14 PM UTC+2, G.W. Haywood wrote:
> Something like this?

Thanks for your input. This would give me the desired result on the client-side 
of things. 

However, I am looking for a way of having bind generate a response containing 
only such a subset before sending it to a client.

___
Please visit https://lists.isc.org/mailman/listinfo/bind-users to unsubscribe 
from this list

bind-users mailing list
bind-users@lists.isc.org
https://lists.isc.org/mailman/listinfo/bind-users


Re: Responding with a subset of an rrset

2018-04-11 Thread G.W. Haywood via bind-users

Hi there,

On Wed, 11 Apr 2018, speijnik wrote:


I'd need a way of returning a random pick of a limited number of
records from a given rrset ...


Something like this?

8<--
#!/usr/bin/perl -w
use strict;
use Net::DNS;
use List::Util qw( shuffle );

sub get_5_random_records
{
my $domain = shift;
my $rrtype = shift;
my @records = ();
my $resolver = Net::DNS::Resolver->new();
$resolver->nameservers( "ns.example.com" );
my $packet = $resolver->send( $domain, $rrtype );
if( ! $packet ) { return undef; }
my $packet_string = $packet->string();
if( $packet_string =~ m/NXDOMAIN/s ) { return undef; }
foreach my $rr ( $packet->answer() ) { if( $rr->type =~ /$rr/i ) { push 
@records, $rr->string; } }
my @shuffled = shuffle @records; # Not that they'll likely need it.
return splice( @shuffled, 0, 5 );
}
8<--

Untested.  Needs work.  YMMV.

--

73,
Ged.
___
Please visit https://lists.isc.org/mailman/listinfo/bind-users to unsubscribe 
from this list

bind-users mailing list
bind-users@lists.isc.org
https://lists.isc.org/mailman/listinfo/bind-users