System Administrator Guide

DNS4J Server


On Linux:

  1. Install Java 6 Runtime Enviroment on you server
  2. download latest DNS4J release from
  3. put downloaded jar in $JRE_HOME/lib/ext
  4. create configurations files:
    • mkdir /etc/dns4j
    • touch /etc/dns4j/nsd.yml
  5. if you choose to use MySQL as zone storage do also:
    • install mysql jdbc driver in $JRE_HOME/lib/ext
    • create database (CREATE DATABASE dns4j)
    • create a database user (GRANT ALL ON dns4j.* TO 'dns4j'@'localhost' IDENTIFIED BY 'password')
    • initialize database (run java it.lorenzoingrilli.dns4j.nsadmin --install-db -j jdbc:mysql://localhost:3306/dns4j --username=dns4j --password=password)
  6. done


The default configuration file is located in /etc/dns4j/nsd.yml

You can configure various component using YAML language:

  • generic components
  • plugins
  • resolvers

A simple configuration file (tcp/udp sever, yaml zones datastore):

&yaml !yamlresolver { file: /etc/dns4j/zones.yml }
!tcp { port: 5053, resolver: *yaml}
!udp { port: 5053, resolver: *yaml}

And example yaml zones file (/etc/dns4j/zones.yml):

- !soa { name:, mname:, rname:, ttl: 300}
- !txt { name:, data: test, ttl: 100 }
- !a { name:, address: }
- !mx { name:, exchange:, preference: 10 }


Command line utilities

Launch name server daemon:

java it.lorenzoingrilli.dns4j.nsd

Supported Resource Records (RR)

Currently dns4j support following kind of resource records: SOA, NS, A, AAAA, MX, CNAME, TXT, HINFO, PTR, SRV
Unknown RR are also supported.


Following resolvers are supported:

  • Yaml Resolver. Shortcut !yamlresolver , you should indicate a 'file' properties, this file is the zones file in yaml format.
  • Database Resolver. Shorcut !dbresolver, you should indicate a 'datasource'.
  •  Scripted Resolver. Shortcut !scriptresolver, you should indicate a 'file' properties. This file is a script which return a DNS Message. All language compatible with "JSR 223: Scripting for the Java™ Platform API" are supported (tested aganist Groovy 1.7 and JRuby 1.9). You can have a statefull script (across multiple executions) by using the 'context' variable (map).