Chapter 85. DNS Component

Available as of Camel version 2.7

This is an additional component for Camel to run DNS queries, using DNSJava. The component is a thin layer on top of DNSJava.
The component offers the following operations:

  • ip, to resolve a domain by its ip
  • lookup, to lookup information about the domain
  • dig, to run DNS queries

INFO:*Requires SUN JVM* The DNSJava library requires running on the SUN JVM.
If you use Apache ServiceMix or Apache Karaf, you’ll need to adjust the etc/ file, to add to the list of Java platform packages exported. The server will need restarting before this change takes effect.

Maven users will need to add the following dependency to their pom.xml for this component:

    <!-- use the same version as your Camel core version -->

85.1. URI format

The URI scheme for a DNS component is as follows


This component only supports producers.

85.2. Options

The DNS component has no options.

The DNS endpoint is configured using URI syntax:


with the following path and query parameters:

85.2.1. Path Parameters (1 parameters):



Required The type of the lookup.



85.2.2. Query Parameters (1 parameters):


synchronous (advanced)

Sets whether synchronous processing should be strictly used, or Camel is allowed to use asynchronous processing (if supported).



85.3. Headers





The domain name. Mandatory.



The name to lookup. Mandatory.



lookup, dig

The type of the lookup. Should match the values of org.xbill.dns.Type. Optional.



lookup, dig

The DNS class of the lookup. Should match the values of org.xbill.dns.DClass. Optional.




The query itself. Mandatory.




The server in particular for the query. If none is given, the default one specified by the OS will be used. Optional.

85.4. Examples

85.4.1. IP lookup

        <route id="IPCheck">
            <from uri="direct:start"/>
            <to uri="dns:ip"/>

This looks up a domain’s IP. For example, resolves to
The IP address to lookup must be provided in the header with key "dns.domain".

85.4.2. DNS lookup

        <route id="IPCheck">
            <from uri="direct:start"/>
            <to uri="dns:lookup"/>

This returns a set of DNS records associated with a domain.
The name to lookup must be provided in the header with key "".

85.4.3. DNS Dig

Dig is a Unix command-line utility to run DNS queries.

        <route id="IPCheck">
            <from uri="direct:start"/>
            <to uri="dns:dig"/>

The query must be provided in the header with key "dns.query".

85.5. Dns Activation Policy

DnsActivationPolicy can be used to dynamically start and stop routes based on dns state.

If you have instances of the same component running in different regions you can configure a route in each region to activate only if dns is pointing to its region.

i.e. You may have an instance in NYC and an instance in SFO. You would configure a service CNAME to point to to bring NYC instance up and SFO instance down. When you change the CNAME to point to — nyc instance would stop its routes and sfo will bring its routes up. This allows you to switch regions without restarting actual components.

	<bean id="dnsActivationPolicy" class="org.apache.camel.component.dns.policy.DnsActivationPolicy">
		<property name="hostname" value="" />
		<property name="resolvesTo" value="" />
		<property name="ttl" value="60000" />

	<route id="routeId" autoStartup="false" routePolicyRef="dnsActivationPolicy">