Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DNS lookup - specify DNS server?

Status
Not open for further replies.

DanglingPointer

Programmer
Apr 5, 2003
22
0
0
GB
Hi

I wanted to write a simple "dig" program that'd perform forward and reverse DNS lookups.

Looking quite easy so far thanks to java.net classes, but there doesn't seem to be anything that allows you to set which DNS server you are querying.

Is there a way to do this?

I expect you could use Datagram and DatagramSocket, but I have no idea of what a DNS Datagram would look like..

Any help appeciated.
 
Brownie is right. See also :


JNDI DNS service provider settings
These properties may not be supported in future releases.
sun.net.spi.nameservice.provider.<n>=<default|dns,sun|...>
Specifies the name service provider that you can use. By default, Java will use the system configured name lookup mechanism, such as file, nis, etc. You can specify your own by setting this option. takes the value of a positive number, it indicates the precedence order with a small number takes higher precendence over a bigger number. In J2SETM 1.4, we have provided one DNS name service provider through JNDI, which is called &quot;dns,sun&quot;.


--------------------------------------------------------------------------------


sun.net.spi.nameservice.nameservers=<server1_ipaddr,server2_ipaddr ...>
You can specify a comma separated list of IP addresses that point to the DNS servers you want to use. If the sun.net.spi.nameservice.nameservers property is not defined, then the provider will use any name servers already configured in the platform DNS configuration.


--------------------------------------------------------------------------------


sun.net.spi.nameservice.domain=<domainname>
This property specifies the default DNS domain name, for instance, eng.sun.com. If the sun.net.spi.nameservice.domain property is not defined then the provider will use any domain or domain search list configured in the platform DNS configuration.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top