IBM Support

How to configure network caching daemon (netcd) to cache DNS answers

Question & Answer


Question

How to configure network caching daemon (netcd) to cache DNS answers

Answer

AIX v6.1 introduced the network caching daemon (netcd), which can be configured to cache answers from DNS, NIS, etc. queries to improve performance and also reduce network traffic to the servers.  In earlier versions, the only workaround was to configure a "caching only" name server.

The following example describes how to configure the "netcd" subsystem to cache the DNS answers. 

- Review AIX documentation for netcd daemon

There is helpful, sample configuration file, "/usr/samples/tcpip/netcd.conf", which includes documentation.

- Edit the netcd configuration file to cache only the DNS queries
The netcd daemon looks for /etc/netcd.conf to use as its configuration file by default. If a configuration file is not detected, netcd uses its default values, which caches all possible data with a hash size of 128, and "time to live" (TTL) of 60 minutes.

The /etc/netcd.conf file does not exist initially.  You must create create the /etc/netcd.conf file.
Add this line to netcd.conf to cache DNS data:

cache dns hosts 128 0

The syntax for the cache option in the netcd.conf file is:
cache <type of cache> <type of map> <hash size> <cache ttl>

This entry caches up to 128 DNS answers. A TTL of zero for DNS means to observe the TTL in the answer from the name server, instead of overwriting it. 

- Start up netcd daemon
The netcd runs under srcmstr.  Use the 'startsrc' and 'stopsrc' commands to stop and restart the daemon.
Start netcd with 'startsrc' command:
# startsrc -s netcd

Note: To start netcd at boot time, uncomment the netcd entry in the /etc/rc.tcpip file.

- Use the 'netcdctrl' command to dump netcd DNS cache data
The netcdctrl commmand enables management of the netcd daemon.

Below is an example on how to use netcdctrl command to dump the DNS cache table:

Initiate a DNS query for yahoo.com:
# host yahoo.com

Dump the netcd dns cache table:
# netcdctrl -t dns -e hosts -a /tmp/out1; cat /tmp/out1
CACHE dns, hosts, name
>>>>>>>>>>>>>>>>>>>>>>>>>>>> ELEM #1
Expiration date : Mon Jun 2 19:05:41 2008
Ulm or resolver name : dns
Query type : 10100002
Query length : 9
Answer (0: positive; 1 : negative) : 0
Query key : 1211245064
String used in query : yahoo.com
Additional parameters in query:
query param1 : 2
query param2 : 0
Length of cached element : 35
################### hostent
Number of aliases = 0
Number of addresses = 2
Type = 2
Type = 2
Length = 4
Host name = yahoo.com
Alias =
Address = 68.180.206.184
Address = 206.190.60.37
#################### end of hostent
>>>>>>>>>>>>>>>>>>>>>>>>>>>> END ELEM #1

END CACHE dns, hosts, name
CACHE dns, hosts, address
END CACHE dns, hosts, address


The data reports that there is one cached DNS entry for yahoo.com in the netcd DNS cache table.

[{"Product":{"code":"SWG10","label":"AIX"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Component":"Not Applicable","Platform":[{"code":"PF002","label":"AIX"}],"Version":"6.1;7.1","Edition":"","Line of Business":{"code":"LOB08","label":"Cognitive Systems"}}]

Document Information

Modified date:
09 November 2021

UID

isg3T1010925