jresolver - The java DNS resolver library
This is a domain name resolver library written in pure java. It is what RFC1034
describes as a stub resolver, in other words it uses a single nameserver to
do the hard work of resolving it's queries. At the moment it only handles
queries for MX records, but it can easily be extended to resolve new types of
queries as needed.
Download
jresolver-0.3.3.zip
Old versions:
Other versions
For developers
I have experimented somewhat with git and now i have set up a readonly
git repository at git.complicata.se.
What's new
091128: There was an error when configuring jresolver with a single
nameserver, as well as a couple of smaller bugfixes. Version 0.3.3 fixes this.
090729: Released version 0.3.1 with support for multiple resolving servers,
parsing of /etc/resolv.conf and DNSSEC. Please see below for more information.
090218: Released a new version 0.2.1 which works as expected on OSX.
Unfortunately it turns out that the networking stack on Linux and OSX differs
when it comes to connected UDP sockets.
Features
- Lightweight. The binary jar is less than at the moment, and has no
exernal dependencies besides JDK 1.4.
- Multi Threaded. It handles multiple concurrent threads sharing a single
Resolver instance.
- Easy to use and develop. The software does one thing, and the code is quite
readable.
- Free software. Released under the GPL 3.0 license, this software can be used,
modified and redistributed by anyone respecting the terms of the license. If you
need other licensing options, please contact me.
Usage
A snippet of code says more than lots of words:
Resolver r = new Resolver("ns.voxbiblia.se");
List l = r.resolve(new MXQuery("voxbiblia.se"));
for (int i = 0; i < l.size(); i++) {
MXRecord mx = (MXRecord)l.get(i);
System.out.println("mx: " + mx.getExchange() + " p: "+ mx.getPreference());
}
If you are on a unix like system and have correct nameserver values in your
/etc/resolv.conf you can call Resolver with no arguments. The nameserver
settings will be deduced from your system configuration.
If you want to build and test the software you need to unpack the files named
jresolver-*-src.tar.bz2 and jresolver-*-test.tar.bz2 and use Apache Ant with
the build.xml file included. You may need to update the test cases with your
dns server names.
DNSSEC
This stub resolver aims to be what RFC4033 calls a non-validating security aware
stub resolver. In practice this means that outgoing requests will contain a
EDNS0 opt bit indicating DNSSEC support as described in RFC3225 and that the
presence of an Authenticated Data (AD) bit in the response from the server is
reflected in the value returned by MXRecord.isVerified() as per the
recommendations in RFC4033 section 7. Please note that this information has
no meaning if you do not trust the security policy of your resolving name
Credits
This software is developed and maintained by Noa Resare with support from
Voxbiblia. Thanks guys for letting me do this! I want to give credit to the
author of dnsjava (http://xbill.org/dnsjava/), a piece of software that I had a
look at before I decided that it would be fun to write my own library with
RFC1035 as a starting point.
Contact
Feel free to write me with comments, suggestions, bug reports and patches.
Noa Resare (noa@voxbiblia.com)