[home][other products][contact me]
[new release: 2.0][download][user's guide][DNSmessage API][domain name system][contact][licensing][to the future][FAQ][java community][some words from  our sponsors]
 
what's new in 2.0?
  1. new GUI interface
  2. preferences file
  3. redirecting output to a file
  4. the list of most recently used nameservers
  5. DNSmessage.class - now it is possible for developers to use nslookup mechanism in applications
system requirements
  For using NS Lookup 2, you need JDK 1.1 to be installed on your system. Versions of several operating systems (e.g. Solaris 2.6) support JDK 1.1-based applications, so you need nothing to install except NS Lookup 2,
download
Download 15 Kb zip-archive (nslookup and DNSmessage classes, DNSmessage API html documentation and a source of simple HelloWorld application). Unzip it on target system and run java nslookup.
contact
If you have any comments or have any problems using NS Lookup 2, please contact with me via e-mail: ketsle@usa.net. If that is a problem with a concrete query - let me know the content of a query and IP-address of a nameserver.  
Also, I would like to receive any comments about DNSmessage class API and any ideas how to make it's methods more friendly and flexible.
license agreement
NS Lookup 2 is free for use for noncommercial purposes. For use a product in any commercial projects you must contact with an author.
references
Here is two sources to read about domain name system and DNS protocol:  
  • RFC 1035 "Domain names - implementation and specification"
  • W. Richard Stevens "TCP/IP Illustrated Vol. 1"
future plans
1999: 
  • console application similar to Unix nslookup utility
  • applet version of NS Lookup 2
  • DNS zone transfer
  • TCP-queries support
second millenium: 
  • NS Lookup space project 
java community
NS Lookup 2 registered in following services: 
www.jars.com 
 
www.java-software.com
counter
 

new release: 2.0

 NS Lookup 2, v. 2.0 is next version of Java NS Lookup. The name of the product has been changed because "Java" is a Sun's trademark, and I am, following for recently received mail from Sun, decide to change the product name. Why NS Lookup "two", I don't know yet. The name has been changed, but product is still written on Java and still looking up.    
 Version 2.0 supports the same, as 1.2, type of queries:  
  • A (resolving hostnames to IP-addresses)
  • PTR (backward query - IP-address to hostname)
  • MX (mail exchange)
  • HINFO (host information) 
  • TXT (descriptive text).
user's guide
 Here is a what NS Lookup 2 GUI looks like: 
nslookup gui 
 To send a query to DNS server, you must: 
  •  In text field Name server type IP-address of DNS server you want to query (e.g. 192.9.9.3). You can type hostname instead address, but that hostname will resolved following your operating system's DNS configuration.  
  • In text field Question type the content of a query - hostname (for A, MX, HINFO or TXT query types), IP-address (for PTR query type) or domain name (for MX query type) which you want to resolve (e.g. cnn.com or 194.220.18.34).  
  • In choice field Query type choose type of query.  
  • Press start query button (the big one at the bottom) and wait for results of the query. Results are looking similar to Solaris (Unix) nslookup utility (with debug option), e.g.:  
-> cnn.com.
   internet address = 207.25.71.22
-> cnn.com.
   internet address = 207.25.71.23
-> cnn.com.
   internet address = 207.25.71.24
AUTHORITY RECORDS:
-> CNN.COM.
   nameserver = NIS.ANS.NET.
-> CNN.COM.
   nameserver = NS.ANS.NET.
ADDITIONAL RECORDS:
-> NIS.ANS.NET.
   internet address = 147.225.1.2
-> NS.ANS.NET.
   internet address = 192.103.63.100
 That means that to cnn.com corresponds three IP-addresses, there are two name servers (nis.ans.net and ns.ans.net), authoritated for cnn.com domain with IP-addresses 147.225.1.2 and 192.103.63.100.  
 rcode field in results can has values NOERROR (all is okay), SERVFAIL (nameserver failed to answer on query) and NAME_ERROR (the requested item does not exist, e.g A query for www.bubble.gum.) 
  About NS Lookup menu: 
  • File/Save output to nsl_out.txt, File/Append output to nsl_out.txt, File/Autoappend output to nsl_out.txt - save  or append results of a query to a file, specified  in .nslookup preferences file. When autoappend option checked, results of each query subsequently append to output file.
  • Name server  - list of recently used nameservers (up to 6). The first entry in list has a permanent value,which not updated when you change nameserver. This values is set in .nslookup file. 
  • Preferences - save options to .nslookup file. If  Save on exit checked, automaticaly save options on exit.
 Here is a sample preferences .nslookup file:  
#NSLookup preferences
#Tue Oct 27 01:22:47 GMT+00:00 1998
nameserver2=134.141.200.220
nameserver1=134.141.208.33
auto_append=true
save_on_exit=false
file=file.out
nameserver=134.141.208.44
The keywords in .nslookup are: 
nameserver permanent name server value can changed by editing .nslookup
nameserver1...5 list of recently used name servers value can changed from GUI
auto_append if true, append results of every query to output file value can changed from GUI
save_on_exit if true, save preferences to .nslookup file value can changed from GUI
file output file name, by default = nsl_out.txt value can changed from GUI
 
FAQ
  1. Is NS Lookup 2 using InetAddress methods  getAddress() and getHostName() for resolving queries? No  it isn't. It implements it's own resolve mechanism.
  2. Where in Internet can I find resources with HINFO and TXT records? It is hard to do. You can try to find HINFO records at irz.inf.tu-dresden.de or ns.sun.ru.
 
DNSmessage API
    As before, NS Lookup 2  product include DNSmessage.class. But only from this release, DNSmessage.class perfomed by set of public and documented methods, which can be used by another Java application to query DNS servers. That is what I call DNSmessage API.
    You can read documentation for DNSmessage.class here online or download with NS Lookup 2 product. If you have any problems with API, pleace e-mail me.
    Please note, that DNS reply consist of answers, authority and additional info portions. Answers portion is  a list of answers for your query (that is why it called so). In authority portion - information about name servers that autoritated for domain to which belong a query, usually that are NS records.  In additional info - usually A records for name servers from authority portion. Every portion can consist from a vary number of records of different types.
    Here is a source of sample java application, that use DNSmessage.class for retrieving MX queries from specified server:
public class HelloWorld extends Object {
public static void main (String argv[]){
  /*
   * creating an instance of DNSmessage class
   */
  DNSmessage dn = new DNSmessage();
  /*
   * default values for name server and domain
   */
  String nameserver = "192.9.9.3", domain = "cnn.com";
  int c;
  /*
   * set, if possible, nameserver and domain values
   */
  if (argv.length >= 2) {
   nameserver = new String(argv[0]);
   domain = new String(argv[1]);
  }
  else if (argv.length == 1)
   domain = new String(argv[0]);
  /*
   * set member variables of class regarding to domain value
   * and MX query type
   */
  dn.setMessage(domain, DNSmessage.QT_MX);
  /*
   * send a query to nameserver
   */
  c = dn.sendMessage(nameserver);
  System.out.println("Nameserver: " + nameserver + ", query: " + domain + ", type = MX.");
  /*
   * if all is okay
   */
  if ( c == 0 ) {
   System.out.println("Waiting for answer ...");
   /*
    * wait while response did not arrive
    */
   while ((c = dn.receiveMessage()) == -1)
    ;
   /*
    * if all is okay
    */
   if ( c == 0) {
    /*
     * if rcode field in response corresponds to NAME_ERROR
     */
    if (dn.getReturnCode() == 3)
     System.out.println("Return code: Name error");
    else
     /*
      * get the answers of type MX from response
      */
     for (int i=0; i < dn.getNumberOfAnswers(); i++)
      if (dn.getType(i) == DNSmessage.QT_MX)
                                                System.out.println("mail exchanger = " + dn.getAnswer(i) + ", preference = " + dn.getMXPreference(i));                 }         }         else                  /*                  * if first command line parameter is unexistent hostname                  */                 if ( c == -1 )                         System.out.println("Unknown host: " + nameserver);     } }
   Here is an output for HelloWorld class:
>java HelloWorld 192.9.9.3 microsoft.com
Nameserver: 192.9.9.3, query: microsoft.com, type = MX.
Waiting for answer ...
mail exchanger = mail4.microsoft.com., preference = 10
mail exchanger = mail5.microsoft.com., preference = 10
mail exchanger = mail1.microsoft.com., preference = 10
mail exchanger = mail2.microsoft.com., preference = 10
mail exchanger = mail3.microsoft.com., preference = 10

 
1