I want to retrieve the DMARC related record of DNS. This has been implemented by this
Asked
Active
Viewed 1,101 times
1 Answers
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
-
note: the above solution uses the dnsjava library (https://github.com/dnsjava/dnsjava). – Manuel M Dec 15 '21 at 12:51