I am messing around with DNS services in Java. I am specifically trying to look up all google.com addresses and display them in an array, similar to running a lookup using nslookup
:
nslookup -q=TXT _netblocks.google.com 8.8.8.8
I am using InetAddress
for this but I keep on getting exceptions. Since the exceptions refer to an 'Unknown Host', I don't think InetAddress
can read TXT records (if I use google.com it works, but that doesn't show the full IP range).
Below is my code:
InetAddress dnsresult[] = InetAddress.getAllByName("_netblocks.google.com");
for (int i=0; i<dnsresult.length; i++)
System.out.println(dnsresult[i]);
I would appreciate it if someone could point me in the right direction.
ping
also can't resolve_netblocks.google.com
. – Termite