#!/usr/bin/perl use Net::DNS; use strict; $|++; my $res = Net::DNS::Resolver->new(); my $dom = shift || 'example.com'; my $count = shift || 10000; my $each = shift || 1000; my $start = time; my $end; for( my $time = $start, my $n = 0; $n<$count; $n++ ) { my $rand = int(rand(2**32-1)); $rand = join(".",unpack("CCCC",pack("H*", sprintf "%08lx", $rand))); $rand .= '.' . $dom; do_query($rand, 'A'); if (($n+1) % $each == 0) { my $t = time; printf "%d %d %d %d\n", $t, $time, $t-$time, int(1000*($t-$time)/$each); $time = $end = $t; } } printf "%d %d %d %d\n", $end, $start, $end-$start, int(1000*($end-$start)/$count); sub do_query { my($query, $type) = @_; my $RR = $res->query($query, $type); if (!$RR && $res->errorstring ne 'NXDOMAIN') { warn "dns: query failed: $query => " . $res->errorstring; } }