From: Sreenivasa M. <mul...@ho...> - 2006-10-26 17:08:24
|
Hello Guys, I am having trouble in adding a row to DNS which is BIND 9.2.5. I am able to ping the server. When I run the program which is below. Nothing goes on to wire atleast. The code is not contacting the server for update or add. Could you please advice me on what could be wrong. Thanks & Regards Sri System.setProperty("sun.net.spi.nameservice.nameservers","192.168.2.3"); System.setProperty("sun.net.spi.nameservice.provider.1", "dns,sun"); System.setProperty("sun.net.spi.nameservice.provider.2", "dns,dnsjava"); public Record addDNSEntry(String zone, int dnsClass, long ttl, String ipAddress ){ String = "ool-18bbc301.arpa.net." Message msg = new Message(); Record record = null; try{ System.out.println("Trying to update the record"); byte[] ipaddressbytearray = Address.toByteArray("195.187.24.1", Address.IPv4); record = Record.newRecord(new Name(zone), Type.A, DClass.IN, ttl, ipaddressbytearray.length, ipaddressbytearray); msg.addRecord(record,Section.ADDITIONAL); log.info("The Entry is updated"); }catch(TextParseException tpe){ log.error(" OOOPs In TextParseException of add DNS entry : "); log.error(tpe.getMessage()); }catch(Exception ioe){ log.error("OOPS In Exception of add DNS entry : "); log.error(ioe.getMessage()); } return record; } |
From: Brian W. <bwe...@xb...> - 2006-10-26 18:02:03
|
On Thu, 26 Oct 2006, Sreenivasa Mulakala wrote: > I am having trouble in adding a row to DNS which is BIND 9.2.5. > > I am able to ping the server. > > When I run the program which is below. Nothing goes on to wire atleast. The > code is not contacting the server for update or add. > > Could you please advice me on what could be wrong. > > Thanks & Regards > Sri > > System.setProperty("sun.net.spi.nameservice.nameservers","192.168.2.3"); > System.setProperty("sun.net.spi.nameservice.provider.1", "dns,sun"); > System.setProperty("sun.net.spi.nameservice.provider.2", "dns,dnsjava"); > > > > public Record addDNSEntry(String zone, int dnsClass, long ttl, String > ipAddress ){ > String = "ool-18bbc301.arpa.net." > > Message msg = new Message(); > Record record = null; > > try{ > System.out.println("Trying to update the record"); > > byte[] ipaddressbytearray = Address.toByteArray("195.187.24.1", > Address.IPv4); > > > record = Record.newRecord(new Name(zone), Type.A, DClass.IN, ttl, > ipaddressbytearray.length, ipaddressbytearray); > > msg.addRecord(record,Section.ADDITIONAL); > log.info("The Entry is updated"); > }catch(TextParseException tpe){ > log.error(" OOOPs In TextParseException of add DNS entry : "); > log.error(tpe.getMessage()); > }catch(Exception ioe){ > log.error("OOPS In Exception of add DNS entry : "); > log.error(ioe.getMessage()); > } > return record; > } You're building a message and never sending it. See the example of using dynamic update at http://www.dnsjava.org/examples.html. Brian |
From: Sreenivasa M. <mul...@ho...> - 2006-10-26 19:26:54
|
Hello Brain, Here is the entry The SOA is 195.187.24.in-addr.arpa IN SOA lab-a.lab.test.net. abuse.test.net. ( 2006101700 ; serial 7200 ; refresh (2 hours) 600 ; retry (10 minutes) 604800 ; expire (1 week) 86400 ; minimum (1 day) ) Here are some sample entries 1 PTR ool-18bbc301.static.goog.net. 10 PTR ool-18bbc30a.static.goog.net. 100 PTR ool-18bbc364.static.goog.net. 101 PTR ool-18bbc365.static.goog.net. 102 PTR ool-18bbc366.static.goog.net. Could you please tell me what I should be doing wrong. For me record is not getting created in the first place. It is returning null. When I try to debug there is a exception like wireparseexception below Here is the data I am passing [-61, -69, -61, 1] in byte array. public Name(DNSInput in) throws WireParseException { int len, pos, currentpos; Name name2; boolean done = false; byte [] label = new byte[MAXLABEL + 1]; boolean savedState = false; while (!done) { len = in.readU8(); switch (len & LABEL_MASK) { case LABEL_NORMAL: if (getlabels() >= MAXLABELS) throw new WireParseException("too many labels"); if (len == 0) { append(emptyLabel, 0, 1); done = true; } else { label[0] = (byte)len; in.readByteArray(label, 1, len); append(label, 0, 1); } break; case LABEL_COMPRESSION: pos = in.readU8(); pos += ((len & ~LABEL_MASK) << 8); if (Options.check("verbosecompression")) System.err.println("currently " + in.current() + ", pointer to " + pos); if (pos >= in.current()) throw new WireParseException("bad compression"); When I do a nsupdate and works for these 1.195.187.24.in-addr.arpa 600 IN PTR www.junk.com. Thanks in advance -Sri >From: Brian Wellington <bwe...@xb...> >To: Sreenivasa Mulakala <mul...@ho...> >CC: dns...@li... >Subject: Re: DNSJAVA Help >Date: Thu, 26 Oct 2006 11:01:45 -0700 (PDT) > >On Thu, 26 Oct 2006, Sreenivasa Mulakala wrote: > >>I am having trouble in adding a row to DNS which is BIND 9.2.5. >> >>I am able to ping the server. >> >>When I run the program which is below. Nothing goes on to wire atleast. >>The >>code is not contacting the server for update or add. >> >>Could you please advice me on what could be wrong. >> >>Thanks & Regards >>Sri >> >> System.setProperty("sun.net.spi.nameservice.nameservers","192.168.2.3"); >> System.setProperty("sun.net.spi.nameservice.provider.1", "dns,sun"); >> System.setProperty("sun.net.spi.nameservice.provider.2", "dns,dnsjava"); >> >> >> >> public Record addDNSEntry(String zone, int dnsClass, long ttl, String >>ipAddress ){ >> String = "ool-18bbc301.arpa.net." >> >> Message msg = new Message(); >> Record record = null; >> >> try{ >> System.out.println("Trying to update the record"); >> >> byte[] ipaddressbytearray = Address.toByteArray("195.187.24.1", >>Address.IPv4); >> >> >> record = Record.newRecord(new Name(zone), Type.A, DClass.IN, ttl, >>ipaddressbytearray.length, ipaddressbytearray); >> >> msg.addRecord(record,Section.ADDITIONAL); >> log.info("The Entry is updated"); >> }catch(TextParseException tpe){ >> log.error(" OOOPs In TextParseException of add DNS entry : "); >> log.error(tpe.getMessage()); >> }catch(Exception ioe){ >> log.error("OOPS In Exception of add DNS entry : "); >> log.error(ioe.getMessage()); >> } >> return record; >> } > >You're building a message and never sending it. See the example of using >dynamic update at http://www.dnsjava.org/examples.html. > >Brian |
From: Brian W. <bwe...@xb...> - 2006-10-26 19:29:55
|
I'm sorry, but I'm not going to help you if you persist in not reading the example code. There's absolutely no reason for you to be constructing byte arrays manually to create DNS records when there are perfectly good methods to create records from either Strings or native objects. Brian |
From: Sreenivasa M. <mul...@ho...> - 2006-10-26 19:51:41
|
Brian, I am sorry to hear this. Actually I am able to add the entry. I did read your examples. I grabbed the code from there only. Here is the code I am using Name zoneName = Name.fromString(zone); Name host = Name.fromString("www.junk.com", zoneName); Update update = new Update(zoneName); update.add(host, Type.PTR, 3600, ipAddress); org.xbill.DNS.Resolver res = new SimpleResolver("10.240.2.21"); res.setTCP(true); Message response = res.send(update); Here are the results Expected one 1 PTR v000f9fd9a094.vo.test.net. Got like this PTR 195.187.195.1 Thanks in advance Regards Sri >From: Brian Wellington <bwe...@xb...> >To: Sreenivasa Mulakala <mul...@ho...> >CC: dns...@li... >Subject: Re: DNSJAVA Help >Date: Thu, 26 Oct 2006 12:29:51 -0700 (PDT) > >I'm sorry, but I'm not going to help you if you persist in not reading the >example code. There's absolutely no reason for you to be constructing byte >arrays manually to create DNS records when there are perfectly good methods >to create records from either Strings or native objects. > >Brian |
From: <og...@og...> - 2006-10-26 20:18:41
|
At 15:51 26/10/2006, Sreenivasa Mulakala wrote: >Brian, > >I am sorry to hear this. > >Actually I am able to add the entry. I did read your examples. I grabbed the >code from there only. > >Here is the code I am using > > Name zoneName = Name.fromString(zone); > Name host = Name.fromString("www.junk.com", zoneName); > Update update = new Update(zoneName); > update.add(host, Type.PTR, 3600, ipAddress); ^^^^^^^^^^^^ Fourth parameter (RDATA) specifies an address you need to change this to the name you want. Olafur |