77
88## Overview
99
10- dnsjava is an implementation of DNS in Java. It supports all defined record
11- types (including the DNSSEC types), and unknown types. It can be used for
12- queries, zone transfers, and dynamic updates. It includes a cache which can be
13- used by clients, and an authoritative only server. It supports TSIG
14- authenticated messages, partial DNSSEC verification, and EDNS0. It is fully
15- thread safe. It can be used to replace the native DNS support in Java.
16-
17- dnsjava was started as an excuse to learn Java. It was useful for testing new
18- features in BIND without rewriting the C resolver. It was then cleaned up and
10+ dnsjava is an implementation of DNS in Java. It supports almost all defined record
11+ types (including the DNSSEC types), and unknown types. It can be used for
12+ queries, zone transfers, and dynamic updates. It includes a cache which can be
13+ used by clients, and an authoritative only server. It supports TSIG
14+ authenticated messages, partial DNSSEC verification, and EDNS0. It is fully
15+ thread safe.
16+
17+ dnsjava was started as an excuse to learn Java. It was useful for testing new
18+ features in BIND without rewriting the C resolver. It was then cleaned up and
1919extended in order to be used as a testing framework for DNS interoperability
20- testing. The high level API and caching resolver were added to make it useful
21- to a wider audience. The authoritative only server was added as proof of
20+ testing. The high level API and caching resolver were added to make it useful
21+ to a wider audience. The authoritative only server was added as proof of
2222concept.
2323
2424## dnsjava on Github
@@ -30,66 +30,215 @@ As of 2019-05-15, Github is
3030[ officially] ( https://sourceforge.net/p/dnsjava/mailman/message/36666800/ )
3131the new home of dnsjava.
3232
33- Please use the Github [ issue tracker] ( https://github.com/dnsjava/dnsjava/issues ) and send - well tested - pull
34- requests. The
33+ Please use the Github [ issue tracker] ( https://github.com/dnsjava/dnsjava/issues )
34+ and send - well tested - pull requests. The
3535[ dnsjava-users@lists.sourceforge.net ] ( mailto:dnsjava-users@lists.sourceforge.net )
3636mailing list still exists.
3737
38- ## Author
39-
40- - Brian Wellington (@bwelling ), March 12, 2004
41- - Various contributors, see [ Changelog] ( Changelog )
42-
4338## Getting started
4439
45- Run ` mvn package ` from the toplevel directory to build dnsjava. JDK 1.4
46- or higher is required.
47-
48- ### Replacing the standard Java DNS functionality:
49-
50- Java versions from 1.4 to 1.8 can load DNS service providers at runtime. The
40+ ### Config options
41+ Some settings of dnsjava can be configured via
42+ [ system properties] ( https://docs.oracle.com/javase/tutorial/essential/environment/sysprop.html ) :
43+
44+ <table >
45+ <thead>
46+ <tr>
47+ <th rowspan="2">Property</th>
48+ <th>Type</th>
49+ <th>Default</th>
50+ <th>Example</th>
51+ </tr>
52+ <tr>
53+ <th colspan="3">Explanation</th>
54+ </tr>
55+ </thead>
56+ <tbody class="rich-diff-level-one">
57+ <tr>
58+ <td rowspan="2">dns.server</td>
59+ <td>String</td>
60+ <td>-</td>
61+ <td>8.8.8.8,[2001:4860:4860::8888]:853,dns.google</td>
62+ </tr>
63+ <tr>
64+ <td colspan="3">DNS server(s) to use for resolving. Comma separated list. Can be IPv4/IPv6 addresses or hostnames (which are resolved using Java's built in DNS support).</td>
65+ </tr>
66+ <tr>
67+ <td rowspan="2">dns.search</td>
68+ <td>String</td>
69+ <td>-</td>
70+ <td>ds.example.com,example.com</td>
71+ </tr>
72+ <tr>
73+ <td colspan="3">Comma separated list of DNS search paths.</td>
74+ </tr>
75+ <tr>
76+ <td rowspan="2">dns.ndots</td>
77+ <td>Integer</td>
78+ <td>1</td>
79+ <td>2</td>
80+ </tr>
81+ <tr>
82+ <td colspan="3">Sets a threshold for the number of dots which must appear in a name given to resolve before an initial absolute query will be made.</td>
83+ </tr>
84+ <tr>
85+ <td rowspan="2">dnsjava.options</td>
86+ <td>option list</td>
87+ <td>-</td>
88+ <td>BINDTTL,tsigfudge=1</td>
89+ </tr>
90+ <tr>
91+ <td colspan="3">Comma separated key-value pairs, see below.</td>
92+ </tr>
93+ <tr>
94+ <td rowspan="2">dnsjava.configprovider.sunjvm.enabled</td>
95+ <td>Boolean</td>
96+ <td>false</td>
97+ <td>true</td>
98+ </tr>
99+ <tr>
100+ <td colspan="3">Set to true to enable the reflection based DNS server lookup, see limitations below.</td>
101+ </tr>
102+ <tr>
103+ <td rowspan="2">dnsjava.udp.ephemeral.start</td>
104+ <td>Integer</td>
105+ <td>49152 (Linux: 32768)</td>
106+ <td>50000</td>
107+ </tr>
108+ <tr>
109+ <td colspan="3">First ephemeral port for UDP-based DNS queries.</td>
110+ </tr>
111+ <tr>
112+ <td rowspan="2">dnsjava.udp.ephemeral.end</td>
113+ <td>Integer</td>
114+ <td>65535 (Linux: 60999)</td>
115+ <td>60000</td>
116+ </tr>
117+ <tr>
118+ <td colspan="3">Last ephemeral port for UDP-based DNS queries.</td>
119+ </tr>
120+ <tr>
121+ <td rowspan="2">dnsjava.udp.ephemeral.use_ephemeral_port</td>
122+ <td>Boolean</td>
123+ <td>false</td>
124+ <td>true</td>
125+ </tr>
126+ <tr>
127+ <td colspan="3">Use an OS-assigned ephemeral port for UDP queries. Enabling this option is insecure! Do NOT use it.</td>
128+ </tr>
129+ </tbody>
130+ </table >
131+
132+ #### dnsjava.options pairs
133+ The dnsjava.options configuration options can also be set programmatically
134+ through the ` Options ` class. Please refer to the Javadoc for details.
135+
136+ | Key | Type | Default | Explanation |
137+ | --- | ---- | -------| ----------- |
138+ | BINDTTL | Boolean | false | Print TTLs in BIND format |
139+ | multiline | Boolean | false | Print records in multiline format |
140+ | noPrintIN | Boolean | false | Don't print the class of a record if it's IN |
141+ | tsigfudge | Integer | 300 | Sets the default TSIG fudge value (in seconds) |
142+ | sig0validity | Integer | 300 | Sets the default SIG(0) validity period (in seconds) |
143+
144+ ### Resolvers
145+ dnsjava comes with several built-in resolvers:
146+ - ` SimpleResolver ` : a basic resolver that uses UDP by default and falls back
147+ to TCP if required.
148+ - ` ExtendedResolver ` : a resolver that uses multiple ` SimpleResolver ` s to send
149+ the queries. Can be configured to query the servers in a round-robin order.
150+ Blacklists a server if it times out.
151+ - ` DohResolver ` : a very basic DNS over HTTP resolver, e.g. to use
152+ ` https://dns.google/query ` .
153+
154+ The project [ dnssecjava] ( https://github.com/ibauersachs/dnssecjava ) has a
155+ resolver that validates responses with DNSSEC.
156+
157+ ### Migrating from version 2.1.x to v3
158+ dnsjava 3 has significant API changes compared to version 2.1.x and is
159+ neither source nor binary compatible. The most important changes are:
160+ - The minimum supported version is Java 8
161+ - Uses [ slf4j] ( http://www.slf4j.org/ ) for logging and thus needs ` slf4j-api `
162+ on the classpath
163+ - The [ command line tools] ( USAGE.md ) were moved to the ` org.xbill.DNS.tools `
164+ package
165+ - On Windows, [ JNA] ( https://github.com/java-native-access/jna ) should be
166+ on the classpath for the search path
167+ - The ` Resolver ` API for custom resolvers has changed to use
168+ ` CompletionStage<Message> ` for asynchronous resolving. The built-in
169+ resolvers are now fully non-blocking and do not start a thread per
170+ query anymore.
171+ - Many methods return a ` List<T> ` instead of an array. Ideally, use a
172+ for-each loop. If this isn't possible, call ` size() ` instead of
173+ using ` length ` :
174+ - Cache#findAnyRecords
175+ - Cache#findRecords
176+ - Lookup#getDefaultSearchPath
177+ - Message#getSectionRRsets
178+ - SetResponse#answers
179+ - ResolverConfig
180+ - RRset returns a List<T > instead of an ` Iterator ` . Ideally, modify your
181+ code to use a for-each loop. If this is not possible, create an iterator
182+ on the returned list:
183+ - RRset#rrs
184+ - RRset#sigs
185+ - Methods using ` java.util.Date ` are deprecated. Use the new versions with
186+ ` java.time.Instant ` or ` java.time.Duration ` instead
187+ - The type hierarchy of ` SMIMEARecord ` changed, it now inherits from
188+ ` TLSARecord ` and constants are shared
189+ - ` Record ` s are no longer marked as ` Serializable ` . Use the RFC defined
190+ serialization formats:
191+ - ` toString() ` , ` rrToString() ` <-> ` fromString() `
192+ - ` toWire() ` <-> ` fromWire() ` , ` newRecord() `
193+ - ` Message ` and ` Header ` properly supported ` clone() `
194+
195+ ### Replacing the standard Java DNS functionality
196+
197+ Java versions from 1.4 to 8 can load DNS service providers at runtime. The
51198functionality was [ removed in JDK 9] ( https://bugs.openjdk.java.net/browse/JDK-8134577 ) ,
52199a replacement is [ requested] ( https://bugs.openjdk.java.net/browse/JDK-8192780 ) ,
53200but so far has not been implemented.
54201
55- To load the dnsjava service provider, build dnsjava on a JDK that still
56- supports the SPI and set the system property:
202+ To load the dnsjava service provider, build dnsjava on JDK 8 and set the system property:
57203
58204 sun.net.spi.nameservice.provider.1=dns,dnsjava
59205
60206This instructs the JVM to use the dnsjava service provide for DNS at the
61207highest priority.
62208
209+ ### Build
63210
64- ## Testing dnsjava
211+ Run ` mvn package ` from the toplevel directory to build dnsjava. JDK 8
212+ or higher is required.
65213
66- [ Matt Rutherford] ( mailto:rutherfo@cs.colorado.edu ) contributed a number of unit
67- tests, which are in the tests subdirectory. The hierarchy under tests
68- mirrors the org.xbill.DNS classes. To run the unit tests, execute
69- ` mvn test ` . The tests require JUnit.
214+ ### Testing dnsjava
70215
71- Some high-level test programs are in ` org/xbill/DNS/tests ` .
216+ [ Matt Rutherford] ( mailto:rutherfo@cs.colorado.edu ) contributed a number of unit
217+ tests, which are in the tests subdirectory. The hierarchy under tests
218+ mirrors the org.xbill.DNS classes. To run the unit tests, execute
219+ ` mvn test ` .
72220
73221
74222## Limitations
75223
76224There's no standard way to determine what the local nameserver or DNS search
77- path is at runtime from within the JVM. dnsjava attempts several methods
225+ path is at runtime from within the JVM. dnsjava attempts several methods
78226until one succeeds.
79227
80228- The properties ` dns.server ` and ` dns.search ` (comma delimited lists) are
81- checked. The servers can either be IP addresses or hostnames (which are
229+ checked. The servers can either be IP addresses or hostnames (which are
82230 resolved using Java's built in DNS support).
83- - The ` sun.net.dns.ResolverConfiguration ` class is queried.
84- - On Unix, ` /etc/resolv.conf ` is parsed.
85- - On Windows, ` ipconfig ` /` winipcfg ` is called and its output parsed. This may
86- fail for non-English versions on Windows.
231+ - On Unix/Solaris, ` /etc/resolv.conf ` is parsed.
232+ - On Windows, if [ JNA] ( https://github.com/java-native-access/jna ) is available
233+ on the classpath, the ` GetAdaptersAddresses ` API is used.
234+ - On Android, depending on the SDK level, either the properties ` net.dns[1234] `
235+ or the ` ConnectivityManager ` is used (requires initialization).
236+ - The ` sun.net.dns.ResolverConfiguration ` class is queried if enabled.
237+ - If available and no servers have been found yet,
238+ [ JNDI-DNS] ( https://docs.oracle.com/javase/8/docs/technotes/guides/jndi/jndi-dns.html ) is used.
87239- As a last resort, ` localhost ` is used as the nameserver, and the search
88240 path is empty.
89241
90- The underlying platform must use an ASCII encoding of characters. This means
91- that dnsjava will not work on OS/390, for example.
92-
93242
94243## Additional documentation
95244
@@ -103,6 +252,12 @@ at [javadoc.io](http://javadoc.io/doc/dnsjava/dnsjava). See the
103252dnsjava is placed under the [ BSD license] ( LICENSE ) . Several files are also under
104253additional licenses; see the individual files for details.
105254
255+ ## Authors
256+
257+ - Brian Wellington (@bwelling ), March 12, 2004
258+ - Various contributors, see [ Changelog] ( Changelog )
259+ - Ingo Bauersachs (@ibauersachs ), current maintainer
260+
106261## Final notes
107262- Thanks to Network Associates, Inc. for sponsoring some of the original
108263 dnsjava work in 1999-2000.
0 commit comments