Here's an example of how to get serial of the SOA record:
SimpleResolver res = new SimpleResolver();
Lookup lookup = new Lookup("google.com", Type.SOA);
lookup.setResolver(res);
Record records[] = lookup.run();
if(records.length > 0 && records[0] instanceof SOARecord){
System.out.println(((SOARecord)records[0]).getSerial());
}else{
System.out.println("Invalid response");
}
_______________________________________
Robert Olofsson, Sweden
http://www.unlogic.se
On 2011-06-22 13:09, Tom Tucker wrote:
>
> I would appreciate some assistance using the getSerial() method. I am
> in the process of learning Java
> so please forgive my ignorance and clumsiness. As you can see below I
> can retrieve the SOA record, but I'm unsure
> how to grab just the serial number field.
>
> Thank you for your time and assistance.
>
>
> import org.xbill.DNS.*;
> import java.util.Iterator;
> import java.net.UnknownHostException;
>
> public class DNSTest1 {
> public static void main(String[] args) throws
> UnknownHostException, TextParseException
> {
> SimpleResolver res = new SimpleResolver("192.168.22.187");
> Lookup lookup = new Lookup("mydomain.com <http://mydomain.com>",
> Type.SOA);
> lookup.setResolver(res);
> lookup.run();
> System.out.println(lookup.getAnswers()[0]);
> }
> }
>
> mydomain.com <http://mydomain.com>.3600INSOAdns1.mydomain.com
> <http://dns1.mydomain.com>. abuse.mydomain.com
> <http://abuse.mydomain.com>. 326178217 10800 3600 1209600 3600
>
>
> ------------------------------------------------------------------------------
> Simplify data backup and recovery for your virtual environment with vRanger.
> Installation's a snap, and flexible recovery options mean your data is safe,
> secure and there when you need it. Data protection magic?
> Nope - It's vRanger. Get your free trial download today.
> http://p.sf.net/sfu/quest-sfdev2dev
>
>
> _______________________________________________
> dnsjava-users mailing list
> dns...@li...
> https://lists.sourceforge.net/lists/listinfo/dnsjava-users
|