in reply to Re: How to create DNS packet
in thread How to create DNS packet

in wireshark, it shows the Query name like "3.www.6.google.3.com"

I think wireshark is being helpful, and showing the label lengths in human readable form, using '.' as a separator (it won't, after all, appear in any label !)

This is a little crude:

sub show { return join('', map { ord($_) > 0x3F ? $_ : sprintf('\\x%02X', ord +($_)) } split(//, $_[0])) ; } ; my $hostname = 'much.ado.about.not.alot.org' ; my @labels = split(/\./, $hostname) ; my $n = scalar(@labels) ; my $question = pack("(C/a*)$n C n2", @labels, 0, 1, 1) ; print "\"", show($question), "\"\n" ;
but gives:
  "\x04much\x03ado\x05about\x03not\x04alot\x03org\x00\x00\x01\x00\x01"
which looks right to me.