You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by Julien Vermillard <jv...@archean.fr> on 2007/06/12 16:35:58 UTC

DNS : RecordStore

Hi !

I started to take a look at ADS DNS provider for fitting my very light
needs.

I simply got two questions :

1# 
In DNS protocol, the RecordStore interface
http://tinyurl.com/2prg84

It would be nice to specify the returned Set type, like :

public interface RecordStore
{
    public Set<ResourceRecord> getRecords( QuestionRecord question ) throws Exception;
}

Due to the lack of javadoc, it could improve the code readability ;)


2#
I made my minimal RecordStore for just resolving few hostname to IP
address. Be carefull, my knowledge of DNS is very low :)

public Set getRecords(QuestionRecord question) throws Exception 
   System.err.println("My store ! : "+question);
   Set<ResourceRecord> set=new HashSet<ResourceRecord>();
   HashMap<String, Object> attr= new HashMap<String, Object>();
   attr.put(DnsAttribute.DOMAIN_NAME,"mydomaine.net");
   attr.put(DnsAttribute.IP_ADDRESS,"192.168.66.66");
   attr.put(DnsAttribute.TYPE,"IN");
   attr.put(DnsAttribute.CLASS,"A");
   ResourceRecord rr=new ResourceRecordImpl("totoz.net",
          RecordType.A,RecordClass.IN,10000,attr);
   set.add(rr);
   return set;
}

dig report me "corrupted reply".

Any idea of what I'm doing wrong ?


Julien


Re: DNS : RecordStore

Posted by Julien Vermillard <jv...@archean.fr>.
Le jeudi 14 juin 2007 à 21:05 -0700, Enrique Rodriguez a écrit :
> On 6/14/07, Enrique Rodriguez <en...@gmail.com> wrote:
> > ...
> > I have duplicated this behavior and I have traced it back to bad
> > encoding introduced in the last patch.  Unfortunately, the bad
> > encoding is reinforced by unit tests that I will have to correct, as
> > well.  I think I will have it sorted out in the next couple hours.
> 
> Hi, Julien,
> 
> I corrected the issue with encoding and was able to verify interop
> with the dig command.
> 
> If you'll 'svn up' you will get the fix as well as 2 new files:  (1) a
> stub implementation of the store called RecordStoreStub that is much
> like your store and (2) a Main class with a main() method for starting
> a DNS server with the stub store.  A couple things to look at:
> 
> a)  The Main class shows how to use a class called "DnsServer" to
> start an instance of a server.  This is what we use in ApacheDS and it
> encapsulates the combination of DNS configuration, a MINA UDP
> acceptor, and a store implementation.  By starting a DnsServer with a
> DnsConfiguration and any store impl you can have a little DNS server.
> This Main uses the stub store but in ApacheDS, of course, we use a
> JNDI store.
> 
> b)  The store stub uses the modifier as I described.
> 
> If you run the Main you can hit the DNS instance by default with:
> 
> $ dig @localhost -p 10053 www.example.com
> 
> I made the store return 2 records to make sure the encoding worked for
> more than one record.
> 
> HTH,
> 
> Enrique

Hi Enrique,

I updated and now it's working like a charm :)

A big thanks ! I'll be able to start adapting it to my needs.


In org.apache.directory.server.dns.service.GetResourceRecords

try
{
    records = store.getRecords( question );
}
catch ( LdapNameNotFoundException lnnfe )
{
    log.debug( "Name for DNS record search does not exist.", lnnfe );
     throw new DnsException( ResponseCode.NAME_ERROR );
}


LdapNameNotFoundException is an ldap exception, perhaps introducing a
new RecordNotFoundException is an idea ?

And changing RecordStore for using Exception subclasses :

public interface RecordStore
{
    public Set<ResourceRecord> getRecords( QuestionRecord question )
throws RecordNotFoundException;
}

That would make the implementation of custom RecordStore easier.

WDYT ?

Julien


Re: DNS : RecordStore

Posted by Enrique Rodriguez <en...@gmail.com>.
On 6/14/07, Enrique Rodriguez <en...@gmail.com> wrote:
> ...
> I have duplicated this behavior and I have traced it back to bad
> encoding introduced in the last patch.  Unfortunately, the bad
> encoding is reinforced by unit tests that I will have to correct, as
> well.  I think I will have it sorted out in the next couple hours.

Hi, Julien,

I corrected the issue with encoding and was able to verify interop
with the dig command.

If you'll 'svn up' you will get the fix as well as 2 new files:  (1) a
stub implementation of the store called RecordStoreStub that is much
like your store and (2) a Main class with a main() method for starting
a DNS server with the stub store.  A couple things to look at:

a)  The Main class shows how to use a class called "DnsServer" to
start an instance of a server.  This is what we use in ApacheDS and it
encapsulates the combination of DNS configuration, a MINA UDP
acceptor, and a store implementation.  By starting a DnsServer with a
DnsConfiguration and any store impl you can have a little DNS server.
This Main uses the stub store but in ApacheDS, of course, we use a
JNDI store.

b)  The store stub uses the modifier as I described.

If you run the Main you can hit the DNS instance by default with:

$ dig @localhost -p 10053 www.example.com

I made the store return 2 records to make sure the encoding worked for
more than one record.

HTH,

Enrique

Re: DNS : RecordStore

Posted by Enrique Rodriguez <en...@gmail.com>.
On 6/14/07, Julien Vermillard <jv...@archean.fr> wrote:
> ...
> I think I'll siwtch back to mina 1.x for see if it's not that

Hi, Julien,

I have duplicated this behavior and I have traced it back to bad
encoding introduced in the last patch.  Unfortunately, the bad
encoding is reinforced by unit tests that I will have to correct, as
well.  I think I will have it sorted out in the next couple hours.

Enrique

Re: DNS : RecordStore

Posted by Julien Vermillard <jv...@archean.fr>.
Le mercredi 13 juin 2007 à 17:35 -0700, Enrique Rodriguez a écrit :
> On 6/13/07, Julien Vermillard <jv...@archean.fr> wrote:
> > Please forget my last message, I pressed send too quicly :)
> >
> > After a little digging in
> > ResourceRecordImpl you have :
> >
> >     public String get( String id )
> >     {
> >         return ( String ) attributes.get( id.toLowerCase() );
> >     }
> >
> > Which return null for my address, due to the "toLowerCase()".
> >
> > Am I supposed to build my Attribute Set using .toLowerCase() for keys ?
> >
> > Like : attr.put(DnsAttribute.IP_ADDRESS.toLowerCase(),"192.168.66.66");
> 
> That will do it, but the intention is for you to use the
> ResourceRecordModifier to create ResourceRecords.  The
> ResourceRecordImpl should be packaged-scoped or something - my bad.
> If you look at ResourceRecordModifier#put the id is toLowerCase()'d
> such that when retrieved with 'get' it works.  IIRC, this was to deal
> with some issues with the case of attributes being returned by our
> Directory store implementation.
> 
> You can re-write your code to instantiate a ResourceRecordModifier.
> Then call sets/puts on the modifier and when you are done call
> getEntry to get a ResourceRecord.  That will handle the needed
> canonicalization.
> 
> Enrique

Ok, so how I build my RessourceRecord :

ResourceRecordModifier rm=new ResourceRecordModifier();
rm.setDnsClass(RecordClass.IN);
rm.setDnsName("www.test.net");
rm.setDnsTtl(100);
rm.setDnsType(RecordType.A);
rm.put(DnsAttribute.IP_ADDRESS.toLowerCase(),"192.168.66.66");
set.add(rm.getEntry());
return set;

Allways the same dig reply :

:~$ dig @192.168.0.228 -p 10053 www.test.net
;; Warning: Message parser reports malformed message packet.

; <<>> DiG 9.3.4 <<>> @192.168.0.228 -p 10053 www.test.net
; (1 server found)
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 64595
;; flags: qr rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;www.test.net.                  IN      A

;; Query time: 52 msec
;; SERVER: 192.168.0.228#10053(192.168.0.228)
;; WHEN: Thu Jun 14 09:32:33 2007
;; MSG SIZE  rcvd: 58

I think I'll siwtch back to mina 1.x for see if it's not that

Julien


Re: DNS : RecordStore

Posted by Enrique Rodriguez <en...@gmail.com>.
On 6/13/07, Julien Vermillard <jv...@archean.fr> wrote:
> Please forget my last message, I pressed send too quicly :)
>
> After a little digging in
> ResourceRecordImpl you have :
>
>     public String get( String id )
>     {
>         return ( String ) attributes.get( id.toLowerCase() );
>     }
>
> Which return null for my address, due to the "toLowerCase()".
>
> Am I supposed to build my Attribute Set using .toLowerCase() for keys ?
>
> Like : attr.put(DnsAttribute.IP_ADDRESS.toLowerCase(),"192.168.66.66");

That will do it, but the intention is for you to use the
ResourceRecordModifier to create ResourceRecords.  The
ResourceRecordImpl should be packaged-scoped or something - my bad.
If you look at ResourceRecordModifier#put the id is toLowerCase()'d
such that when retrieved with 'get' it works.  IIRC, this was to deal
with some issues with the case of attributes being returned by our
Directory store implementation.

You can re-write your code to instantiate a ResourceRecordModifier.
Then call sets/puts on the modifier and when you are done call
getEntry to get a ResourceRecord.  That will handle the needed
canonicalization.

Enrique

Re: DNS : RecordStore

Posted by Julien Vermillard <jv...@archean.fr>.
Please forget my last message, I pressed send too quicly :)

After a little digging in 
ResourceRecordImpl you have :

    public String get( String id )
    {
        return ( String ) attributes.get( id.toLowerCase() );
    }

Which return null for my address, due to the "toLowerCase()".

Am I supposed to build my Attribute Set using .toLowerCase() for keys ?

Like : attr.put(DnsAttribute.IP_ADDRESS.toLowerCase(),"192.168.66.66");

Julien





Le mercredi 13 juin 2007 à 11:27 +0200, Julien Vermillard a écrit :
> in 
> 
>     /**
>      * Returns the raw IP address of this <code>InetAddress</code>
>      * object. The result is in network byte order: the highest order
>      * byte of the address is in <code>getAddress()[0]</code>.
>      *
>      * @return  the raw IP address of this object.
>      */
>     public byte[] getAddress() {
> 	return null;
>     }
> Le mercredi 13 juin 2007 à 11:10 +0200, Julien Vermillard a écrit :
> > Le mardi 12 juin 2007 à 14:15 -0700, Enrique Rodriguez a écrit :
> > > On 6/12/07, Julien Vermillard <jv...@archean.fr> wrote:
> > > > ...
> > > > 1#
> > > > In DNS protocol, the RecordStore interface
> > > > http://tinyurl.com/2prg84
> > > 
> > > I added your suggestion, re: generics and some minor Javadocs.  I
> > > recently completed a Javadoc run on Kerberos and Change Password and
> > > DNS was on my TODO list.  I'll step it up.
> > > 
> > > > 2#
> > > > I made my minimal RecordStore for just resolving few hostname to IP
> > > > address. Be carefull, my knowledge of DNS is very low :)
> > > >
> > > > public Set getRecords(QuestionRecord question) throws Exception
> > > >    System.err.println("My store ! : "+question);
> > > >    Set<ResourceRecord> set=new HashSet<ResourceRecord>();
> > > >    HashMap<String, Object> attr= new HashMap<String, Object>();
> > > >    attr.put(DnsAttribute.DOMAIN_NAME,"mydomaine.net");
> > > >    attr.put(DnsAttribute.IP_ADDRESS,"192.168.66.66");
> > > >    attr.put(DnsAttribute.TYPE,"IN");
> > > >    attr.put(DnsAttribute.CLASS,"A");
> > > >    ResourceRecord rr=new ResourceRecordImpl("totoz.net",
> > > >           RecordType.A,RecordClass.IN,10000,attr);
> > > >    set.add(rr);
> > > >    return set;
> > > > }
> > > >
> > > > dig report me "corrupted reply".
> > > >
> > > > Any idea of what I'm doing wrong ?
> > > 
> > > Just eyeballing it, the only thing in 'attr' should be IP address.
> > > The rest is redundant (and domain name conflicts) with the info put
> > > into the RR constructor.
> > > 
> > > What is your dig statement?  If you query for "mydomaine.net" but are
> > > returning "totoz.net" that could give you a problem.  With the above
> > > code you should be dig'ing:
> > > 
> > > $ dig totoz.net
> > > 
> > > and getting "192.168.66.66".
> > > 
> > > Your reply could also be corrupted if UDP/TCP isn't being handled
> > > properly.  Our DNS provider doesn't have TCP support, though it is
> > > trivial to add with MINA.  TCP uses a 2-byte pre-pended size, which
> > > could be throwing off the client-side decode.
> > > 
> > > Enrique
> > 
> > I use a DatagramAcceptor
> > 
> > I made that test :
> > Set<ResourceRecord> set=new HashSet<ResourceRecord>();
> > HashMap<String, Object> attr= new HashMap<String, Object>();
> > 
> > attr.put(DnsAttribute.IP_ADDRESS,"192.168.66.66");
> > ResourceRecord rr=new
> > ResourceRecordImpl("totoz.net",RecordType.A,RecordClass.IN,10000,attr);
> > set.add(rr);
> > return set;
> > 
> > dig result : 
> > 
> > :~$ dig @192.168.0.228 -p 10053 www.totoz.net
> > Warning: Message parser reports malformed message packet.
> > 
> > ; <<>> DiG 9.3.4 <<>> @192.168.0.228 -p 10053 www.totoz.net
> > ; (1 server found)
> > ;; global options:  printcmd
> > ;; Got answer:
> > ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 23978
> > ;; flags: qr rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
> > 
> > ;; QUESTION SECTION:
> > ;www.totoz.net.                 IN      A
> > 
> > ;; Query time: 11 msec
> > ;; SERVER: 192.168.0.228#10053(192.168.0.228)
> > ;; WHEN: Wed Jun 13 11:04:24 2007
> > ;; 
> > 
> > The binary dump of query and the reply :
> > 
> > http://rafb.net/p/Qb1QSm95.html
> > 
> > Julien
> > 
> > I'm going to look in the codec, I prolly missed something.
> > 



Re: DNS : RecordStore

Posted by Julien Vermillard <jv...@archean.fr>.
in 

    /**
     * Returns the raw IP address of this <code>InetAddress</code>
     * object. The result is in network byte order: the highest order
     * byte of the address is in <code>getAddress()[0]</code>.
     *
     * @return  the raw IP address of this object.
     */
    public byte[] getAddress() {
	return null;
    }
Le mercredi 13 juin 2007 à 11:10 +0200, Julien Vermillard a écrit :
> Le mardi 12 juin 2007 à 14:15 -0700, Enrique Rodriguez a écrit :
> > On 6/12/07, Julien Vermillard <jv...@archean.fr> wrote:
> > > ...
> > > 1#
> > > In DNS protocol, the RecordStore interface
> > > http://tinyurl.com/2prg84
> > 
> > I added your suggestion, re: generics and some minor Javadocs.  I
> > recently completed a Javadoc run on Kerberos and Change Password and
> > DNS was on my TODO list.  I'll step it up.
> > 
> > > 2#
> > > I made my minimal RecordStore for just resolving few hostname to IP
> > > address. Be carefull, my knowledge of DNS is very low :)
> > >
> > > public Set getRecords(QuestionRecord question) throws Exception
> > >    System.err.println("My store ! : "+question);
> > >    Set<ResourceRecord> set=new HashSet<ResourceRecord>();
> > >    HashMap<String, Object> attr= new HashMap<String, Object>();
> > >    attr.put(DnsAttribute.DOMAIN_NAME,"mydomaine.net");
> > >    attr.put(DnsAttribute.IP_ADDRESS,"192.168.66.66");
> > >    attr.put(DnsAttribute.TYPE,"IN");
> > >    attr.put(DnsAttribute.CLASS,"A");
> > >    ResourceRecord rr=new ResourceRecordImpl("totoz.net",
> > >           RecordType.A,RecordClass.IN,10000,attr);
> > >    set.add(rr);
> > >    return set;
> > > }
> > >
> > > dig report me "corrupted reply".
> > >
> > > Any idea of what I'm doing wrong ?
> > 
> > Just eyeballing it, the only thing in 'attr' should be IP address.
> > The rest is redundant (and domain name conflicts) with the info put
> > into the RR constructor.
> > 
> > What is your dig statement?  If you query for "mydomaine.net" but are
> > returning "totoz.net" that could give you a problem.  With the above
> > code you should be dig'ing:
> > 
> > $ dig totoz.net
> > 
> > and getting "192.168.66.66".
> > 
> > Your reply could also be corrupted if UDP/TCP isn't being handled
> > properly.  Our DNS provider doesn't have TCP support, though it is
> > trivial to add with MINA.  TCP uses a 2-byte pre-pended size, which
> > could be throwing off the client-side decode.
> > 
> > Enrique
> 
> I use a DatagramAcceptor
> 
> I made that test :
> Set<ResourceRecord> set=new HashSet<ResourceRecord>();
> HashMap<String, Object> attr= new HashMap<String, Object>();
> 
> attr.put(DnsAttribute.IP_ADDRESS,"192.168.66.66");
> ResourceRecord rr=new
> ResourceRecordImpl("totoz.net",RecordType.A,RecordClass.IN,10000,attr);
> set.add(rr);
> return set;
> 
> dig result : 
> 
> :~$ dig @192.168.0.228 -p 10053 www.totoz.net
> Warning: Message parser reports malformed message packet.
> 
> ; <<>> DiG 9.3.4 <<>> @192.168.0.228 -p 10053 www.totoz.net
> ; (1 server found)
> ;; global options:  printcmd
> ;; Got answer:
> ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 23978
> ;; flags: qr rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
> 
> ;; QUESTION SECTION:
> ;www.totoz.net.                 IN      A
> 
> ;; Query time: 11 msec
> ;; SERVER: 192.168.0.228#10053(192.168.0.228)
> ;; WHEN: Wed Jun 13 11:04:24 2007
> ;; 
> 
> The binary dump of query and the reply :
> 
> http://rafb.net/p/Qb1QSm95.html
> 
> Julien
> 
> I'm going to look in the codec, I prolly missed something.
> 
After a little digging in 
ResourceRecordImpl you have :

    public String get( String id )
    {
        return ( String ) attributes.get( id.toLowerCase() );
    }

Which return null for my address, due to the "toLowerCase()".

Julien


Re: DNS : RecordStore

Posted by Enrique Rodriguez <en...@gmail.com>.
On 6/13/07, Julien Vermillard <jv...@archean.fr> wrote:
> ...
> I use a DatagramAcceptor
>
> I made that test :
> Set<ResourceRecord> set=new HashSet<ResourceRecord>();
> HashMap<String, Object> attr= new HashMap<String, Object>();
>
> attr.put(DnsAttribute.IP_ADDRESS,"192.168.66.66");
> ResourceRecord rr=new
> ResourceRecordImpl("totoz.net",RecordType.A,RecordClass.IN,10000,attr);
> set.add(rr);
> return set;
>
> dig result :
>
> :~$ dig @192.168.0.228 -p 10053 www.totoz.net
> Warning: Message parser reports malformed message packet.

FWIW, you are querying for 'www.totoz.net', but the A record you have
created is only for 'totoz.net'.  With A records, the question record
domain name and the resource record domain name should match.
'totoz.net' is a legitimate host name so your A record says
'totoz.net' has the given IP address, not that your query is for an A
record subordinate to the 'totoz.net' domain.

In any case, your problem is the null address as discussed next.

Enrique

Re: DNS : RecordStore

Posted by Julien Vermillard <jv...@archean.fr>.
Le mardi 12 juin 2007 à 14:15 -0700, Enrique Rodriguez a écrit :
> On 6/12/07, Julien Vermillard <jv...@archean.fr> wrote:
> > ...
> > 1#
> > In DNS protocol, the RecordStore interface
> > http://tinyurl.com/2prg84
> 
> I added your suggestion, re: generics and some minor Javadocs.  I
> recently completed a Javadoc run on Kerberos and Change Password and
> DNS was on my TODO list.  I'll step it up.
> 
> > 2#
> > I made my minimal RecordStore for just resolving few hostname to IP
> > address. Be carefull, my knowledge of DNS is very low :)
> >
> > public Set getRecords(QuestionRecord question) throws Exception
> >    System.err.println("My store ! : "+question);
> >    Set<ResourceRecord> set=new HashSet<ResourceRecord>();
> >    HashMap<String, Object> attr= new HashMap<String, Object>();
> >    attr.put(DnsAttribute.DOMAIN_NAME,"mydomaine.net");
> >    attr.put(DnsAttribute.IP_ADDRESS,"192.168.66.66");
> >    attr.put(DnsAttribute.TYPE,"IN");
> >    attr.put(DnsAttribute.CLASS,"A");
> >    ResourceRecord rr=new ResourceRecordImpl("totoz.net",
> >           RecordType.A,RecordClass.IN,10000,attr);
> >    set.add(rr);
> >    return set;
> > }
> >
> > dig report me "corrupted reply".
> >
> > Any idea of what I'm doing wrong ?
> 
> Just eyeballing it, the only thing in 'attr' should be IP address.
> The rest is redundant (and domain name conflicts) with the info put
> into the RR constructor.
> 
> What is your dig statement?  If you query for "mydomaine.net" but are
> returning "totoz.net" that could give you a problem.  With the above
> code you should be dig'ing:
> 
> $ dig totoz.net
> 
> and getting "192.168.66.66".
> 
> Your reply could also be corrupted if UDP/TCP isn't being handled
> properly.  Our DNS provider doesn't have TCP support, though it is
> trivial to add with MINA.  TCP uses a 2-byte pre-pended size, which
> could be throwing off the client-side decode.
> 
> Enrique

I use a DatagramAcceptor

I made that test :
Set<ResourceRecord> set=new HashSet<ResourceRecord>();
HashMap<String, Object> attr= new HashMap<String, Object>();

attr.put(DnsAttribute.IP_ADDRESS,"192.168.66.66");
ResourceRecord rr=new
ResourceRecordImpl("totoz.net",RecordType.A,RecordClass.IN,10000,attr);
set.add(rr);
return set;

dig result : 

:~$ dig @192.168.0.228 -p 10053 www.totoz.net
Warning: Message parser reports malformed message packet.

; <<>> DiG 9.3.4 <<>> @192.168.0.228 -p 10053 www.totoz.net
; (1 server found)
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 23978
;; flags: qr rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;www.totoz.net.                 IN      A

;; Query time: 11 msec
;; SERVER: 192.168.0.228#10053(192.168.0.228)
;; WHEN: Wed Jun 13 11:04:24 2007
;; 

The binary dump of query and the reply :

http://rafb.net/p/Qb1QSm95.html

Julien

I'm going to look in the codec, I prolly missed something.


Re: DNS : RecordStore

Posted by Enrique Rodriguez <en...@gmail.com>.
On 6/12/07, Julien Vermillard <jv...@archean.fr> wrote:
> ...
> 1#
> In DNS protocol, the RecordStore interface
> http://tinyurl.com/2prg84

I added your suggestion, re: generics and some minor Javadocs.  I
recently completed a Javadoc run on Kerberos and Change Password and
DNS was on my TODO list.  I'll step it up.

> 2#
> I made my minimal RecordStore for just resolving few hostname to IP
> address. Be carefull, my knowledge of DNS is very low :)
>
> public Set getRecords(QuestionRecord question) throws Exception
>    System.err.println("My store ! : "+question);
>    Set<ResourceRecord> set=new HashSet<ResourceRecord>();
>    HashMap<String, Object> attr= new HashMap<String, Object>();
>    attr.put(DnsAttribute.DOMAIN_NAME,"mydomaine.net");
>    attr.put(DnsAttribute.IP_ADDRESS,"192.168.66.66");
>    attr.put(DnsAttribute.TYPE,"IN");
>    attr.put(DnsAttribute.CLASS,"A");
>    ResourceRecord rr=new ResourceRecordImpl("totoz.net",
>           RecordType.A,RecordClass.IN,10000,attr);
>    set.add(rr);
>    return set;
> }
>
> dig report me "corrupted reply".
>
> Any idea of what I'm doing wrong ?

Just eyeballing it, the only thing in 'attr' should be IP address.
The rest is redundant (and domain name conflicts) with the info put
into the RR constructor.

What is your dig statement?  If you query for "mydomaine.net" but are
returning "totoz.net" that could give you a problem.  With the above
code you should be dig'ing:

$ dig totoz.net

and getting "192.168.66.66".

Your reply could also be corrupted if UDP/TCP isn't being handled
properly.  Our DNS provider doesn't have TCP support, though it is
trivial to add with MINA.  TCP uses a 2-byte pre-pended size, which
could be throwing off the client-side decode.

Enrique