자바로 DNS 를 조회해보자..
package demo;
import java.net.UnknownHostException;
import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.NamingException;
import javax.naming.directory.DirContext;
import javax.naming.directory.InitialDirContext;
public class test {
public static void main(String[] args) throws NamingException, UnknownHostException {
<span style="text-decoration: underline;">Hashtable</span> env = new <span style="text-decoration: underline;">Hashtable</span>();
<span style="text-decoration: underline;">env</span><span style="text-decoration: underline;">.</span><span style="text-decoration: underline;">put</span><span style="text-decoration: underline;">(</span><span style="text-decoration: underline;">Context</span><span style="text-decoration: underline;">.</span><span style="text-decoration: underline;">INITIAL_CONTEXT_FACTORY</span><span style="text-decoration: underline;">,</span> <span style="text-decoration: underline;">"com.sun.jndi.dns.DnsContextFactory"</span><span style="text-decoration: underline;">)</span>;
DirContext ictx = new InitialDirContext(env);
String dnsServers = (String) ictx.getEnvironment().get("java.naming.provider.url");
System.out.println("DNS Servers: " + dnsServers );
}
}