1

I want to retrieve the DMARC related record of DNS. This has been implemented by this

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Sudarshan
  • 51
  • 6

1 Answers1

4
private void performDNSLookup(String address) {
    try {
        Resolver resolver = new SimpleResolver();
        Lookup lookup = new Lookup(address, Type.TXT);
        lookup.setResolver(resolver);
        Record[] record = lookup.run();
        for (int i = 0, len = record.length; i < len; i++)
            System.out.println(record[i].rdataToString() + "\n"
                    + record.length);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}

Use the above method where address is the DMARC URL for the given domain.

For eg: If one want to view DMARC record of google.com then the URL ,ie., address in given function is _dmarc.google.com. If null is returned then the domain doesn't have any DMARC record.

Sudarshan
  • 51
  • 6