ms_dns_query

DNS Functions (MS_DNS)

Resolves the IP address of a host.

char *ms_dns_query( char *transaction,  char *dnsserverURL, [char*  IPversion], [char *query_host,] [char *local_address,] LAST ); 

transactionA transaction name for this step in quotes. To instruct VuGen not to create a transaction for this step, use a NULL string, "".
dnsserverURLThe IP address of the DNS server as a URL: "URL=dns://server_ip:port" (The default port is 53)
IPversionThe IP version. The value is 4 or 6.
For example, "IPversion=6"
The default is 4.
query_host The hostname to resolve:"QueryHost=hostname"
local_address A local address for IP spoofing:"LocalAddr=local_ip:port"
LAST A marker indicating the end of the argument list.

The ms_dns_query function resolves the IP address(es) of the specified host name, using a Domain Name Service (DNS). This function does not automatically add the domain to the hostname, you need to include it explicitly.

The ms_dns_query function returns a pointer to a list of IP addresses for the specified hostname, delimited by NULL characters. The first IP address corresponds to the first address returned in the DNS query results. To advance to the next result in the list, use ms_dns_nextresult.

A script that calls ms_dns_query must have an #include "mic_socket.h" statement.

Return Values

If this function succeeds, it returns a pointer to a list of IP addresses for the specified hostname, delimited by NULL characters. Otherwise, it returns LR_FAIL.

Parameterization

All arguments of this function of the type char, can be parameterized with standard parameterization.

Example

In the following example, the ms_dns_query resolves the IP address for a server.

    
Copy code
#include "mic_socket.h" 

    char *results = NULL;
    int   rescnt  = 0;
    
    lr_load_dll ( "micsocket.dll" );

    lr_save_string("123.456.789.012","DnsServer");    // Set DNS server IP Address
    lr_save_string("myserver.mydomain", "Hostname");  // Set hostname to resolve

    // Perform DNS Query
    results = (char *) ms_dns_query("DnsQuery",
            "URL=dns://{DnsServer}",
            "IPversion=6",
            "QueryHost={Hostname}",
             LAST);

    // List the results
    while (*results) {
        rescnt++;
        lr_log_message(
            lr_eval_string("(%d) IP address for {Hostname} is %s"),
            rescnt,
            results);
        results = (char *) ms_dns_nextresult(results);
    }