DNS traceroute

| July 22nd, 2009

This helps tracking down bottlenecks in DNS response from recursive queries.

First you need a DNS query payload (contents of a valid udp DNS A type query).

$hostname = “www.google.com”;
$header = pack(“n C2 n4″, 6666, 1, 0, 1, 0, 0, 0);

for (split(/\./,$hostname)) {
$lformat .= “C a* “;
$labels[$count++]=length;
$labels[$count++]=$_;
}

$question = pack($lformat.”C n2″, @labels, 0, 1, 1);

open(PACKET, ‘>>dns_packet.txt’);
print PACKET $header.$question;
close(PACKET);

and now use this payload with hping2 to send udp packets:

hping -2 -p 53 -E dns_packet.txt -d 39 -T xxx.yyy.zzz.xyz

Leave a Reply

You must be logged in to post a comment.