How to configure network caching daemon (netcd) to cache DNS answers
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 respective servers.
This document will show you to configure the "netcd" subsystem to cache DNS answers. Prior to AIX v6.1, there wasn't an option to cache client DNS queries. The only workaround was to configure a caching only name server.
Here are the details:
- Review AIX documentation for netcd daemon
Here's a link to AIX v6.1 man page entry for netcd daemon
Here's a link to the netcd.conf man page:
Here's a link to AIX v6.1 Differences Guide Redbook:
See Chapter 7.5 in above document.
There's also a sample netcd configuration file named /usr/samples/tcpip/netcd.conf that is self documenting and very helpful.
- Edit the netcd configuration file to only cache DNS queries
The netcd daemon will look for /etc/netcd.conf to use as its configuration file by default. If a configuration file is not detected, netcd will use its default values, which will cache 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, so if this is your first time, you will need to create a new 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>
The above entry will cache 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. See the documentation referenced above for more detailed informatoin.
- Start up netcd daemon
The netcd runs under srcmstr, so the 'startsrc' and 'stopsrc' commands should be used to start and stop it, respectively.
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 allows you to manage the netcd daemon.
Here's an example on how to use netcdctrl command to dump the DNS cache table:
Initiate a DNS query for yahoo.com:
# nslookup 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
Number of aliases = 0
Number of addresses = 2
Type = 2
Length = 4
Host name = yahoo.com
Address = 188.8.131.52
Address = 184.108.40.206
#################### end of hostent
>>>>>>>>>>>>>>>>>>>>>>>>>>>> END ELEM #1
END CACHE dns, hosts, name
CACHE dns, hosts, address
END CACHE dns, hosts, address
The above data shows that there is one cached DNS entry for yahoo.com in the netcd DNS cache table.
Please refer to resources mentioned above for more detailed information.