rescached is domain name service cache, it caching internet name and address on local memory when running and in local disk when not running.
rescached is not a reimplementation of DNS server like BIND. rescached primary goal is only to caching DNS queries and answers, used by personal or small group of users, to minimize unneeded traffic to outside network.Features,
A short story on how DNS work in your system.
When you opened some website, let say www.reddit.com, in a browser, the first thing that browser do is to translate name address www.reddit.com into an internet address (i.e.: 18.104.22.168) so browser can make a connection to www.reddit.com server.
How browser do that ? First, it will send query to one of DNS server listed in your system configuration (/etc/resolv.conf in Unix). Then, if your DNS server also "caching" the name that you requested, it will reply the answer (internet address) directly, if it is not then it will ask to their parent DNS server.
+----+ +----------------+ +------------------+ | PC | <==> | ISP DNS Server | <==> | Other DNS Server | <==> ... +----+ +----------------+ +------------------+
If you browsing frequently on the same site, hitting the refresh button, opening a page on the same website, etc.; this procedures will always repeated every times.
To make this repetitive procedures less occurred, you can run rescached in your personal computer. The first time answer is received in your local computer, rescached will saved it in computer memory and any later request of the same address will be answered directly by rescached
+----+ +----------------+ +------------------+ | PC | | ISP DNS Server | <==> | Other DNS Server | <==> ... +----+ +----------------+ +------------------+ ^^ ^^ || || vv || +-----------+ || | rescached | <==// +-----------+
The only request that send to your DNS server is the one that does not already exist in rescached.
rescached in technical side of view.
Each of query and answer data in cache have a number of accessed field, which defined how the cache will be ordered in memory. The frequently queried host-name will be at the top of cache list, and less queried host-name will at the bottom of cache list. This, obviously, will make a cache list based on user habit (frequently accessed host-name), which effect on the search time on cache list: fast reply.
+-----+-----------------+ | # | host-name | +-----+-----------------+ | 529 | www.reddit.com | +-----+-----------------+ | 233 | www.google.com | +-----+-----------------+ | ... | ... | +-----+-----------------+ | 1 | www.kilabit.org | +-----+-----------------+
The number of cache that rescached can hold in memory is depend on the value of cache.max in configuration file. When the number of cache in memory reached it cache.max value, it will remove all cache data that has the number of frequently accessed less than cache.threshold.
$ git clone http://www.github.com/shuLhan/rescached.git rescached.git $ git clone http://www.github.com/shuLhan/libvos.git libvos.git $ cd rescached.git/src $ ln -s ../../libvos.git lib $ make
After program successfully build, you can install it manually or using make program.
Installing using make in linux system using init.d (I.e. OpenSuSE) use,
$ sudo make install
For Arch linux, which use rc.d, use,
$ sudo make install-arch
Assume that we use directory "/etc/rescached" as configuration directory, then
$ sudo mkdir /etc/rescached $ sudo cp rescached.cfg /etc/rescached
In example we use "/var/cache/rescached" as cache directory,
$ sudo mkdir /var/cache/rescached
If you use different cache directory, do not forget to change the configuration option.
$ sudo cp build/rescached /usr/sbin
If you want your program running each time the system is up you can create a system startup script. You can see an example for openSuSE startup script in file scripts/rescached.run, or scripts/rescached.arch for Arch Linux system.
This step is really different between each system, consult your distribution forum or mailing-list for how to create system startup script.
Edit rescached configuration, /etc/rescached/rescached.cfg, change the value of server.parent based on your preferred DNS server.
$ sudo mv /etc/resolv.conf /etc/resolv.conf.org $ sudo echo "nameserver 127.0.0.1" > /etc/resolv.conf
After rescached has been installed you can start, stop, and view status of rescached service using /sbin/rcrescached.
$ sudo /sbin/rcrescached start
$ sudo /sbin/rcrescached stop
$ sudo /sbin/rcrescached status
All rescached startup option located in file /etc/rescached/rescached.cfg. In this file you can see some comment for any option and some possible value. This section will explain more about each option and how they effect rescached.
|Value||A path to a cache file.|
|Description||This file contain all DNS answers that rescached collected while running. When rescached stopped it will saved all DNS answer in this file, so when rescached is started again it will load all data in this file to memory again. If not set, then rescached will load/save the cache to the file named rescached.vos in current directory where user running rescached.|
|Value||A name of of backup file, with or without path.|
|Default||file.data + ".bak"|
|Description||This file is a backup of file.data, it will be created only if rescached program exit successfully without error. If not set then it will have the same name with the value in file.data but with additional suffix, .bak.|
|Value||A path to process id file.|
|Description||When rescached program started, it will create this file as a mediator to any system service. Content of this file is process ID (PID) of rescached program in system. If not set then the default name will be used, and it will be saved in current directory where user running rescached.|
|Value||A name of rescached log file.|
|Description||This file contain log of program when running. Verbosity of log output is depend on value of debug option.|
|Value||List of parent DNS servers, separated by commas.|
|Format||IP-ADDRESS:PORT, IP-ADDRESS:PORT, ...|
When rescached receive a query from client and when it does not have a cached
address of query, it will pass the query to those parent server.
rescached use a Google DNS public server as a default parent address if not set. The reason for this is that Google DNS public server use a simple and small size of response/answer. Please, do not use OpenDNS server, because OpenDNS will reply with it own address, instead of replying with no answer, if certain host-name not found (i.e. typo in host-name), this will make rescached caching a false data.
To check if your parent server reply the unknown host-name with no answer, use dig tool.
|Value||Local IP address that rescached will listening for client request.|
|Description||Address in local network where rescached will listening for query from client. If you want rescached to serve a query from another host in your local network, change this value to 0.0.0.0|
|Value||Port for listening for client request|
|Format||Any number between 1 to 65535|
|Description||Beside the server.listen address, rescached also need to known which port it will opening for receiving client queries. You should not change this value, because technically every client (browser, email client, etc.) will always send the query to port 53.|
|Value||Timeout value, in second, before cleaning queue.|
|Format||Any number between 300 to 2147483647.|
|Description||This option set the server timeout value. If time out is reached, all the old queries (that is older than server.timeout) in queue that does not receipt a reply from parent server will be removed.|
|Value||Maximum number of host-name and address that will keep in memory.|
|Format||Any number between 1 and 2147483647.|
|Description||When rescached running it will keep all queries and answers in memory as much as cache.max. The bigger the cache.max value, then the more rescached will use memory.|
|Value||Minimum value for cache status.|
|Format||Any number between 1 and 2147483647.|
|Description||When rescached cache all the queries and answers, until long enough it will reached it own maximum value (cache.max), when it happen rescached will remove all cache that their number-of-queried value is less than cache.threshold.|
|Value||cache mode, affect how the cache will be saved in disk/memory.|
|Format||Number between 1 and 2.|
If cache.mode is set to 1, all DNS record will be keep forever, no
possible query or renewed DNS record happen until the specific DNS record
removed from cache.
If cache.mode is set to 2 (default), all DNS record will be keep only after the specific time, based on maximum TTL value in DNS record. If TTL is reached, hostname will be queried again to the DNS parent server, and old cache and TTL value will be replaced with a new one.
|Format||Any number between 0 and 2.|
|Description||This option only used by developer for debugging program.|