0

Is there a way to listen to DNS changes using Java? I'm looking to update an external system with DNS changes as they happen.

Existing solution is to listen to bind.log for changes.

phoenix2010
  • 3,633
  • 1
  • 13
  • 10

2 Answers2

0

This is similar to this question: Resolving ip-address of a hostname

To resolve a host in Java:

InetAddress address = InetAddress.getByName("www.example.com"); 

Now you could run this on a separate Thread and listen for the change:

public void launchThread()
{
    Thread thread = new Thread(new Runnable()
    {
        InetAddress start = InetAddress.getByName("www.example.com");
        while(start.equals(InetAddress.getByName("www.example.com")))
        {
            try
            {
                Thread.sleep(1000);
            }catch(Exception e){e.printStackTrace();}
        }

        System.out.println("Domain resolution has changed.");
    })
}
Community
  • 1
  • 1
John
  • 3,769
  • 6
  • 30
  • 49
  • I'm looking for changes that happen on the DNS with all the entries, like new entries or updates. I'm NOT interested in the IP change of a particular FQDN. – phoenix2010 Apr 27 '15 at 22:47
0

Monitoring a DNS server for changes over the internet requires that you are granted DNS zone transfer access (AXFR/IXFR). Once you have zone transfer access, you can pull a copy of the DNS data held by the server, but without such permission your options are rather limited. For instance, you can poll the server for RR changes for known names, but you can't possibly detect new names using just public DNS access.

Another alternative is to use a passive DNS data provider, but the coverage these provide may be limited and the service might be expensive. At least one of the major providers of passive DNS data works by tapping into DNS traffic, so they see new names and changes as they appear in DNS traffic.

PeterK
  • 3,667
  • 2
  • 17
  • 24