com.lavantech.net.dns
Class SimpleDNSLookup

java.lang.Object
  extended bycom.lavantech.net.dns.SimpleDNSLookup

public class SimpleDNSLookup
extends java.lang.Object

SimpleDNSLookup class provides simple methods to perform most common DNS lookups. If you are looking for more functionality, see DNSLookup class. Here are some examples of its use.

  
  InetAddress addr = SimpleDNSLookup.getInetAddress("www.hotmail.com");
  String hostname = SimpleDNSLookup.getHostName(addr);
  String mailExchange = SimpleDNSLookup.getMailExchange("hotmail.com");
  
  

See Also:
DNSLookup

Field Summary
static int timeout
          Timeout for DNS lookup for all static methods in this class.
 
Constructor Summary
SimpleDNSLookup()
           
 
Method Summary
static java.lang.String getCanonicalName(java.lang.String hostname)
          Returns the Canonical Name for a given hostname.
static java.lang.String getDomainAdminMailBox(java.lang.String domain)
          Returns the admin email id for the given domain.
static java.lang.String getHostName(java.net.InetAddress addr)
          Returns the hostname for a given IP Address.
static java.net.Inet6Address getInet6Address(java.lang.String hostname)
          Returns the IPv6 address for a given hostname.
static java.net.InetAddress getInetAddress(java.lang.String hostname)
          Returns an IP Address for a given hostname.
static java.lang.String getMailExchange(java.lang.String domain)
          Returns the mail exchange for a given domain.
static java.lang.String getNameServerForDomain(java.lang.String domain)
          Returns the Name Server for a given domain.
static java.lang.String getTextInformation(java.lang.String hostname)
          Returns the text information for the given hostname.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

timeout

public static int timeout
Timeout for DNS lookup for all static methods in this class. The default value is 10000 (10 Seconds). A value of 0 means no timeout (wait forever for response). Change it per your requirment.

Constructor Detail

SimpleDNSLookup

public SimpleDNSLookup()
Method Detail

getInetAddress

public static java.net.InetAddress getInetAddress(java.lang.String hostname)
                                           throws java.lang.Exception
Returns an IP Address for a given hostname.

Parameters:
hostname - Hostname for which the IP address should be returned.
Returns:
IP address of the given hostname. null if no record is found.
Throws:
java.net.SocketTimeoutException - If the response is not received within the timeout period.
java.lang.Exception - If the Name Server can't be determined or any other internal error occurs.

getHostName

public static java.lang.String getHostName(java.net.InetAddress addr)
                                    throws java.lang.Exception
Returns the hostname for a given IP Address.

Parameters:
addr - IPAddress for which the hostname should be returned.
Returns:
Hostname for the given IP address. null if no record is found.
Throws:
java.net.SocketTimeoutException - If the response is not received within the timeout period.
java.lang.Exception - If the Name Server can't be determined or any other internal error occurs.

getMailExchange

public static java.lang.String getMailExchange(java.lang.String domain)
                                        throws java.lang.Exception
Returns the mail exchange for a given domain.

Parameters:
domain - Domain for which the responsible Mail Exchange should be returned.
Returns:
Mail Exchange for the given domain. null if no record is found.
Throws:
java.net.SocketTimeoutException - If the response is not received within the timeout period.
java.lang.Exception - If the Name Server can't be determined or any other internal error occurs.

getInet6Address

public static java.net.Inet6Address getInet6Address(java.lang.String hostname)
                                             throws java.lang.Exception
Returns the IPv6 address for a given hostname.

Parameters:
hostname - Hostname for which the IPv6 address should be returned.
Returns:
IPv6 address for the given hostname. null if no record is found.
Throws:
java.net.SocketTimeoutException - If the response is not received within the timeout period.
java.lang.Exception - If the Name Server can't be determined or any other internal error occurs.

getCanonicalName

public static java.lang.String getCanonicalName(java.lang.String hostname)
                                         throws java.lang.Exception
Returns the Canonical Name for a given hostname.

Parameters:
hostname - Hostname for which the Canonical name should be returned.
Returns:
Canonical hostname for the given hostname. null if no record is found.
Throws:
java.net.SocketTimeoutException - If the response is not received within the timeout period.
java.lang.Exception - If the Name Server can't be determined or any other internal error occurs.

getNameServerForDomain

public static java.lang.String getNameServerForDomain(java.lang.String domain)
                                               throws java.lang.Exception
Returns the Name Server for a given domain.

Parameters:
domain - Domain for which the Name Server should be returned.
Returns:
Name Server for the given domain. null if no record is found.
Throws:
java.net.SocketTimeoutException - If the response is not received within the timeout period.
java.lang.Exception - If the Name Server can't be determined or any other internal error occurs.

getDomainAdminMailBox

public static java.lang.String getDomainAdminMailBox(java.lang.String domain)
                                              throws java.lang.Exception
Returns the admin email id for the given domain.

Parameters:
domain - Domain for which the administrator's email should be returned.
Returns:
Email id of the administrator for the given domain. null if no record is found.
Throws:
java.net.SocketTimeoutException - If the response is not received within the timeout period.
java.lang.Exception - If the Name Server can't be determined or any other internal error occurs.

getTextInformation

public static java.lang.String getTextInformation(java.lang.String hostname)
                                           throws java.lang.Exception
Returns the text information for the given hostname.

Parameters:
hostname - Hostname for which the text information should be returned.
Returns:
Text information for the hostname. null if no record is found.
Throws:
java.net.SocketTimeoutException - If the response is not received within the timeout period.
java.lang.Exception - If the Name Server can't be determined or any other internal error occurs.