• Post Reply Bookmark Topic Watch Topic
  • New Topic

nslookup in java supplying different DNS

 
Swapnil Sapar
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm looking for a way to get IP address for a given host and given DNS.

something like ...

Now I know I can use following but here I dont get a chance to specify my own DNS server - 10.11.12.13. I dont see any InetAddress API that allow me to specify my DNS.

I really don't want to use Runtime.exec() to actually run nslookup command, instead I'm looking for a java API or third party library API.

Thanks,
Swapnil
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The DNSJava library can do this. You can specify which DNS server to user via a SimpleResolver, and you'd be looking up "A" records for IPv4 addresses and "AAAA" records for IPv6 addresses.
 
Rob Spoor
Sheriff
Posts: 20822
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'll move this to our Sockets and Internet Protocols forum.
 
Swapnil Sapar
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the replies. I found the solution that uses com.sun.jndi.dns.DnsContextFactory.
Here is the link to the HttpClient-User mailing list - HttpClient-User
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found the solution that uses com.sun.jndi.dns.DnsContextFactory.

If it works for you - great. It's very much inferior to DNSJava, though.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!