Quicklinks
The Domain Name System (DNS) is the method by which Internet addresses in mnemonic form - such as www.activexperts.com - are converted into the equivalent numeric IP address such as 212.97.55.136. To the user and application process this translation is a service provided either by the local host or from a remote host via the Internet. The DNS server (or resolver) may communicate with other Internet DNS servers if it cannot translate the address itself.
DNS names are constructed hierarchically. The highest level of the hierarchy is the last component or label of the DNS address.
Labels can be up to 63 characters long and are not case sensitive. A maximum length of 255 characters is allowed.
Labels must start with a letter and can only consist of letters, digits and hyphens.
Nslookup is a popular program for UNIX, LINUX and Windows to query Internet domain name servers. It allows the user to query name servers for information about various hosts and domains or to print a list of hosts in a domain.
ActiveSocket provides an easy-to-use development/scripting interface to use the same operations as NsLookup, through the DnsServer class. By using ActiveSocket, you can very easily create or enhance Windows applications/scripts with DNS lookup features.
ActiveSocket features the following: DNS, FTP, HTTP, HTTPs, ICMP Ping, IP-to-Country, MSN, NTP, RSH, SCP, SFTP, SNMP v1/v2c (Get, GetNext, Set), SNMP Traps, SNMP MIB, SSH, TCP, Telnet, TFTP, UDP, Telnet, Wake-On-LAN and more.
When using HTML, there are two ways to install the ActiveSocket Toolkit on a client PC:
You can install the ActiveSocket Toolkit automatically using the following HTML code on top of the HTML page:
<head> <object codebase="http://www.activexperts.com/files/network-component/3.1/asocket.cab" classid="CLSID:B52B14BA-244B-4006-86E0-2923CB69D881" ></object> </head>
The ActiveSocket Toolkit will be installated automatically. The user will be asked to confirm the installation, because the DLL is coming from an untrusted site (www.activexperts.com).
There are two ways to avoid prompting:
On each client PC, download the ActiveSocket Toolkit from the ActiveXperts Download Site and start the installation. The installation guides you through the installation process.
You must use Javascript to declare and create the object:
var objDnsServer; objDnsServer = new ActiveXObject ( "ActiveXperts.DnsServer" );
You can now query DNS servers.
The following HTML code shows how to create a DNS client:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>ActiveSocket DNS Demo</title>
<object codebase="http://www.activexperts.com/files/network-component/3.1/asocket.cab" classid="CLSID:B52B14BA-244B-4006-86E0-2923CB69D881" ></object>
<script language="JavaScript" type="text/javascript">
function Lookup ()
{
var objDnsServer = new ActiveXObject ( "ActiveXperts.DnsServer" );
var objConstants = new ActiveXObject ( "ActiveXperts.ASConstants" );
objDnsServer.LogFile = textLogfile.value;
objDnsServer.Server = textServer.value;
objDnsServer.Lookup ( textAddress.value, 255 );
textQueryResult.value = "";
if ( objDnsServer.LastError == 0 )
{
var objDnsRecord = objDnsServer.GetFirstRecord ();
while ( objDnsServer.LastError == 0 )
{
switch ( objDnsRecord.Type )
{
case objConstants.asDNS_TYPE_A:
textQueryResult.value += "\r\nType : A";
textQueryResult.value += "\r\n\tName :" + objDnsRecord.Name;
textQueryResult.value += "\r\n\tAddress :" + objDnsRecord.Address;
break;
case objConstants.asDNS_TYPE_AAAA:
textQueryResult.value += "\r\nType : AAAA";
textQueryResult.value += "\r\n\tName :" + objDnsRecord.Name;
textQueryResult.value += "\r\n\tAddress :" + objDnsRecord.Address;
break;
case objConstants.asDNS_TYPE_CNAME:
textQueryResult.value += "\r\nType : CNAME";
textQueryResult.value += "\r\n\tName :" + objDnsRecord.Name;
textQueryResult.value += "\r\n\tAlias :" + objDnsRecord.Address;
break;
case objConstants.asDNS_TYPE_MX:
textQueryResult.value += "\r\nType : MX";
textQueryResult.value += "\r\n\tName: " + objDnsRecord.Name;
textQueryResult.value += "\r\n\tPreference :" + objDnsRecord.Preference;
textQueryResult.value += "\r\n\tMailExchange :" + objDnsRecord.MailExchange;
break;
case objConstants.asDNS_TYPE_NS:
textQueryResult.value += "\r\nType : NS";
textQueryResult.value += "\r\n\tName :" + objDnsRecord.Name;
textQueryResult.value += "\r\n\tNameServer :" + objDnsRecord.NameServer;
break;
case objConstants.asDNS_TYPE_PTR:
textQueryResult.value += "\r\nType : PTR";
textQueryResult.value += "\r\n\tName :" + objDnsRecord.Name;
textQueryResult.value += "\r\n\tAddress :" + objDnsRecord.Address;
break;
case objConstants.asDNS_TYPE_SOA:
textQueryResult.value += "\r\nType : SOA";
textQueryResult.value += "\r\n\tName :" + objDnsRecord.Name;
textQueryResult.value += "\r\n\tNameServer :" + objDnsRecord.NameServer;
textQueryResult.value += "\r\n\tMailBox: " + objDnsRecord.MailBox;
textQueryResult.value += "\r\n\tSerial: " + objDnsRecord.SerialNumber;
textQueryResult.value += "\r\n\tRefreshInterval: " + objDnsRecord.RefreshInterval;
textQueryResult.value += "\r\n\tRetryInterval: " + objDnsRecord.RetryInterval;
textQueryResult.value += "\r\n\tExpirationLimit: " + objDnsRecord.ExpirationLimit;
textQueryResult.value += "\r\n\tMinimumTTL: " + objDnsRecord.MinimumTTL;
break;
}
objDnsRecord = objDnsServer.GetNextRecord ();
}
}
if ( objDnsServer.LastError == 22355 )
{
textResult.value = "0 : Success";
}
else
{
textResult.value = objDnsServer.LastError + " : " + objDnsServer.GetErrorDescription ( objDnsServer.LastError );
}
}
</script>
</head>
<body>
<font face="sans-serif" size="2">
<hr size="1" color="#707070">
<b><font size="4">ActiveXperts ActiveSocket HTML/JavaScript Sample</font></b>
<br>
<br>
Perform a DNS lookup of the given hostname.
<br>
<br>
<hr size="1" color="#707070">
<br>
<table border="0" bgcolor="#f0f0f0" ID="table1" >
<tr>
<td width="120" valign="top">DNS Server:</td>
<td width="450">
<input size="50" type="text" id="textServer" value="ns1.interstroom.nl" >
</td>
</tr>
<tr>
<td width="120" valign="top">Host:</td>
<td width="450">
<input size="50" type="text" id="textAddress" value="activexperts.com" >
</td>
</tr>
<tr>
<td width="120" valign="top">Logfile:</td>
<td width="450">
<input size="50" type="text" id="textLogfile" value="C:\DnsLog.txt" >
</td>
</tr>
<tr>
<td width="120" valign="top">IP Address:</td>
<td width="450">
<textarea rows="12" id="textQueryResult" cols="54"></textarea>
</td>
</tr>
<tr>
<td vAlign="top">Result:</td>
<td>
<input size="50" type="text" id="textResult" value="N/A" >
</td>
</tr>
<tr>
<td>
</td>
<td>
<input type="button" onclick="Lookup()" value="Lookup">
</td>
</tr>
</table>
<br>
<hr size="1" color="#707070">
</body>
</html>
There are many working samples included with the product. You can also find them on the ActiveXperts FTP site: ftp.activexperts-labs.com/samples/network-component.