Use the nslookup command in JAVA
With dnsjava tools, you can easily achieve nslookup simulation, dnsjava official website, dnsjava-2.1.7.jar download
Package cn. baokx; import java.net. inetAddress; import java.net. unknownHostException; import org. xbill. DNS. lookup; import org. xbill. DNS. record; import org. xbill. DNS. textParseException; import org. xbill. DNS. type; public class NetWork {public static void main (String [] args) throws UnknownHostException, TextParseException {InetAddress address = InetAddress. getByName ("baidu.com"); System. out. println (address. get HostAddress (); // query the IP address Lookup lookup = new Lookup ("baidu.com", Type. a); lookup. run (); if (lookup. getResult ()! = Lookup. SUCCESSFUL) {System. out. println ("ERROR:" + lookup. getErrorString (); return;} Record [] answers = lookup. getAnswers (); for (Record rec: answers) {System. out. println (rec. toString ());}}}