Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP-UX IP Address and Client Management Administrator’s Guide: HP-UX 11i v2, HP-UX 11i v3 > Chapter 2 Configuring and Administering the BIND Name Service

Configuring the Resolver to Set Timeout Values

» 

Technical documentation

Complete book in PDF
» Feedback
Content starts here

 » Table of Contents

 » Index

You can configure the timeout value for clients that use DNS to resolve a host name. The timeout value specifies the number of retransmissions of a query and the time (in milliseconds) between each retransmission. The performance of the resolver improves with smaller timeout values. You can configure the timeout values by defining environment variables, editing the /etc/resolv.conf configuration file, or using the resolver APIs.

Configuring Timeout Values Using Environment Variables

You can set the retransmission value and the time between each retransmission by using the environment variables RES_RETRY and RES_RETRANS, respectively. The valid values for the RES_RETRY and RES_RETRANS environment variables are positive non-zero integers. By default, the system attempts to retransmit 4 times, and the time interval between each retransmission is 5000 milliseconds.

NOTE: You can set the timeout values with the environment variables RES_RETRY and RES_RETRANS only for individual clients.

If the environment variables RES_RETRY and RES_RETRANS contain invalid values, the default values are set and an error message is logged in the /var/adm/syslog/syslog.log file.

To set the environment variables, type the following export commands at the HP-UX prompt:

# export RES_RETRY=1
# export RES_RETRANS=300

This sets the retransmission value to 1 and the time between each retransmission to 300 milliseconds. You can specify the export commands again to change the values for both the environment variables. Do not specify a value less than 200 milliseconds for the RES_RETRANS environment variable.

Configuring Timeout Values Using the Configuration File

You can specify the retransmission time and the time between each retransmission by using the options retrans and retry, respectively, in the /etc/resolv.conf configuration file.

NOTE: You can set the timeout values in the configuration file /etc/resolv.conf only for a specific system.

To set the timeout values, add the following lines to the /etc/resolv.conf configuration file after the domain and name server entries.

retry     1
retrans    600

This sets the retransmission value to 1 and the time between each retransmission to 600 milliseconds.

Configuring Timeout Values Using APIs

You can configure the timeout values using the following APIs:

  • set_resfield()

  • get_resfield()

Using these two APIs, you can set and get values for the retransmission time and the time between each retransmission in the instance of the a _res_state structure. When you configure the timeout values using the APIs, you must make certain changes to the code and recompile the code. The returned values of the APIs indicate if the specified values are correct.

The set_resfield() API

The syntax for the set_resfield function is as follows:

set_resfield(int field, void *value)

The set_resfield() function contains two parameters: field and *value. You can set the resolver option using the field parameter and the value for the field using the value parameter.

The set_resfield() function returns either 0 or -1. It returns a value0 if the function successfully sets the value for the resolver option in the instance of the_res_state structure, which holds all the resolver options. A value of -1 denotes a failure to set the resolver option.

The get_resfield() API

The syntax for the get_resfield() function is as follows:

get_resfield(int field, void *value, sizeof value)

The get_resfield() function contains three parameters: field, *value, and value. The parameter field contains the resolver option. The parameter *value is the pointer to the location where the option value is stored. The value parameter specifies the memory (in bytes) allocated for a variable when a function is invoked.

The get_resfield() function returns either 0 or -1. It returns a value of 0 if the function successfully gets the value of the field in the value parameter and returns a value -1 on failure.

Sample Program with Timeout Values

A sample program with timeout values is as follows:

main()
{
       int retrans = 600;
       int retry =1;
       struct hostent *hp;
       struct in_addr ia;
       char *name = “localhost”;
       res_init();
       set_resfield(RES_RETRANS, &retrans);
       set_resfield(RES_RETRY, &retry);
       hp = gethostbyname (name);
       if (hp == NULL )
        {
           printf (“gethostbyname failed\n”);
           herror(“Error”);
         }
         else
         {
            int i;
            for (i=o; hp->h_addr_list[i]; i++)
            {
              memcpy((caddr_t)&ia, hep->h_addr_list[i],\
                                           sizeof(ia));
              printf(“%s”, inet_ntoa(ia));
            }
         }

   get_resfield (RES_RETRANS, &retrans, sizeof retrans);
   get_resfield (RES_RETRY, &retry, sizeof retry);
   printf (“retry = %d \n retrans = %d\n”, retry,retrans);
}
Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© Hewlett-Packard Development Company, L.P.