Skip to content

Getting Started

Osman Shoukry edited this page Mar 31, 2018 · 2 revisions

System Requirements

  1. Java 1.7 - 1.8.
  2. Latest DNSControl jar (see Latest on GitHub or through Maven Central)
  3. DNSJava 2.1.8 (see Maven Central)

Starting up

  1. CLASSPATH: Make sure your startup CLASSPATH has DNSControl & DNSJava jars in it. (i.e. add manually to startup script, or put in your application server's lib folder (i.e. TOMCAT/lib)
  2. Create your dns routing configuration file, the file format is simple properties format with key = value. The key is the destination you'd like to override and value is the DNS servers to utilize for this destination.
    For example:
# Selection order is more specific wins
# For example, if you have a host, domain, and default override, they will be processed in that order.
# The left hand side is the destination to override, the right hand is the list of dns servers to use.
# Left hand entries should be unique, one entry per destination.
# Don't need to suffix your entries with "." dot, this is implied, meaning, default domain will not be appended.

# Setup default DNS servers, this is optional.
# If not defined, the current host DNS servers will be used if unset (i.e. resolv.conf).
.=10.0.0.1,10.0.0.2

# Override DNS lookups for specific hosts
www.openpojo.com=10.1.1.1

# Override DNS lookups for whole domains (starts with "." dot),
# This will override lookups for *.openpojo.com (i.e. some.host.openpojo.com)
.openpojo.com=10.0.2.2

# Suppress any queries that you'd like to never resolve
hiddenhost.openpojo.com=

# Finally if you want to use your current system's DNS servers without having to know the entries.
unchanged.resolution.openpojo.com=SYSTEM
  1. Set your environment values, ultimately Java should start and have the following two parameters at a minimum set on it:
    3.1. sun.net.spi.nameservice.provider.1=dns,dnscontrol
    3.2. dnscontrol.conf.file=</path/where/dns_control_file>
java -Dsun.net.spi.nameservice.provider.1=dns,dnscontrol \
     -Ddnscontrol.conf.file=/path/where/dns_control_file
  • Note: If you're using Tomcat you can export your environment variables to be included like this:
export CATALINA_OPTS="-Dsun.net.spi.nameservice.provider.1=dns,dnscontrol dnscontrol.conf.file=/path/where/dns_control_file"
  1. Watch the logs you should see some entries that look like this:
19-Mar-2018 16:16:48.572 INFO [main] com.openpojo.dns.service.java.v7.JavaNameServiceDescriptor.<init> Descriptor service initialized
19-Mar-2018 16:16:48.585 INFO [main] com.openpojo.dns.routing.impl.RoutingTableBuilder.build building routing table with route [.=[10.0.0.1, 10.0.0.2]]... Resolver set to[org.xbill.DNS.ExtendedResolver@5702b3b1]
19-Mar-2018 16:16:48.586 INFO [main] com.openpojo.dns.routing.impl.RoutingTableBuilder.build building routing table with route [.com.openpojo.www=[10.1.1.1]]... Resolver set to[org.xbill.DNS.ExtendedResolver@4b952a2d]
19-Mar-2018 16:16:48.587 INFO [main] com.openpojo.dns.routing.impl.RoutingTableBuilder.build building routing table with route [.com.openpojo.=[10.0.2.2]]... Resolver set to[org.xbill.DNS.ExtendedResolver@3159c4b8]
19-Mar-2018 16:16:48.587 INFO [main] com.openpojo.dns.routing.impl.RoutingTableBuilder.build building routing table with route [.com.openpojo.hiddenhost=[]]... Resolver set to[com.openpojo.dns.resolve.NoOpResolver@69ea3742]
19-Mar-2018 16:16:48.593 INFO [main] com.openpojo.dns.service.java.v7.JavaNameService.<init> Java name service initialized

Clone this wiki locally