You are not logged in.

#1 2010-08-21 15:37:16

ms
Member
From: Bandung, Indonesia
Registered: 2010-07-28
Posts: 68
Website

rescached - yet another DNS/resolver cache daemon

Hello Archers,

In the spirit of scratch-my-own-itch, I created another DNS cache tool called rescached.

Rescached is a daemon that act as a DNS server, serve the clients queries, but also caching all that queries for later use. Unlike any other name-service daemon, rescached save all of cache objects when program exit and loaded it back to memory when started back.

History.

I have a slow and unstable connection. Back then, I try anything to minimize all outgoing data by caching and tweaking all my traffic (squid, privoxy, web browser caches, blocking images, etc.). Until I found about djbdnsd and I cannot install it. So, long story short I created my own DNS cache. This was a few weeks before I know about pdnsd, and my program already half way finished so I just continue it, beside that I learn many thing about DNS protocol.

Since Archer always want to know what the system do, if you want to view what your system request each time, edit file "/etc/rescached/rescached.cfg" and set option "debug" to "1".

  • For non-technical explanation you can read it here [1].

  • For user documentation you can read it here [2].

  • AUR package is here [3].

  • Source is here [4].

Quick installation,

  1. Install package from AUR.

  2. Change your name server,

    $ sudo cp /etc/resolv.conf /etc/resolv.conf.org
    $ sudo echo "nameserver 127.0.0.1" > /etc/resolv.conf
  3. Restart rescached

    $ sudo systemctl restart rescached
  4. Do not forget to restart any application (browser, email, etc) to make it read new /etc/resolv.conf.

All feedbacks is welcome.


Thank you all,

ms

--
[1] http://www.kilabit.info/journal/2009/12 … ed_is_here
[2] http://www.kilabit.info/projects/rescached/doc/user/
[3] https://aur4.archlinux.org/packages/rescached-git/
[4] https://github.com/shuLhan/rescached

UPDATE:
2015.07.06

  • Update hosts ads.

  • New config option "server.parent.connection". This allow rescached connect to parent server using UDP or TCP.

  • Fixes on TCP request handle.

  • Startup and logs.

2014.12

  • Many major fix (memory leaks, DNS type for AAAA, multiple answers, serving /etc/hosts)

  • Ads blocking by hostname (Credit to http://pgl.yoyo.org for providing the list).

2010

  • fix link #1 in this post.

  • rescached updated to version 2010.11.18.2123.

Last edited by ms (2015-07-19 01:37:24)

Offline

#2 2010-08-27 03:22:17

superchango
Member
From: Tenochtitlan
Registered: 2009-01-22
Posts: 132

Re: rescached - yet another DNS/resolver cache daemon

Sound great, i'll tet it in my system now.

Thnxs!!


"Yo creo que los muertos son tiernos. ¿Nos besamos?"

Offline

#3 2010-08-28 10:38:07

gtklocker
Member
Registered: 2009-09-01
Posts: 460

Re: rescached - yet another DNS/resolver cache daemon

Awesome program. It improved my browsing speed very much. big_smile

Offline

#4 2010-08-31 23:25:28

ms
Member
From: Bandung, Indonesia
Registered: 2010-07-28
Posts: 68
Website

Re: rescached - yet another DNS/resolver cache daemon

Well, thank you all, especially to superchango and gtklocker for direct replies, for already trying my program.

It's really feel greats to create something that can be useful for others.

Just a quick note, in case some one missed it from the last section in documentation,

There is a problem with DNS caching. Sometimes domain name change their IP address with a new IP address. Since old IP address is already cached in rescached program, and your program still use an old IP address, program cannot connect to the specific domain name. You can notice this happen when the program staled (loading infinitely) or failed to connect.

There is only two solution.

First, stop rescached program, delete the cache file and start the rescached program back. This will start the program back with an empty cache.

Second, stop rescached program, edit cache file, delete specific record based on the domain name that have the problem, and restart the rescached program back. Be careful when doing this, make sure you really delete one record (you can see in cache file that each record start with "domain.name" and end with character "|").

Currently there is no "easy" way (I.e. automatic detection) and simple solution to this problem yet. But, if anyone have an idea or solution I will listen to it.

Last edited by ms (2010-08-31 23:27:38)

Offline

#5 2010-09-01 00:39:27

faelar
Member
From: Amiens (FR)
Registered: 2007-12-18
Posts: 232
Website

Re: rescached - yet another DNS/resolver cache daemon

Can you do the following ? :

- There is something cached, let's call it "olddata".
- Things have changed since last time so in reality what we need here is "newdata".

1. The user make a request.
2. rescached answers with "olddata".
3. rescached start a query.
4. cache is updated with "newdata".

It doesn't resolve the problem for the first query, but on a second time thing will be ok without any user intervention.

Offline

#6 2010-09-01 05:20:32

yejun
Member
Registered: 2009-10-21
Posts: 66

Re: rescached - yet another DNS/resolver cache daemon

Have you tried unbound which support prefetching and dnssec.

And glibc also comes with a dns caching /etc/rc.d/nscd

Most modern browsers have buildin dns prefetching and caching.

Edit:
Bind and dnsmasq are also worth trying.

Last edited by yejun (2010-09-01 13:47:32)

Offline

#7 2010-09-01 10:59:19

ms
Member
From: Bandung, Indonesia
Registered: 2010-07-28
Posts: 68
Website

Re: rescached - yet another DNS/resolver cache daemon

@faelar,

If rescached do that for every request from client, then it break the main
purpose of rescached it self: to minimize traffic to outside network.

What make rescached different with others DNS cache daemon is the caches is
permanent, once the host-name "A" is already cached there is no way the same
query go outside of the network again. I tried to keep it that way. That is
why rescached is best used only for personal use, when DNS traffic data only
about host-name and email address. [1]

The only solution that come to my mind right now is by using a custom Time To
Live (TTL) value. In example refresh "old-data" if older than 1 day, or 1 week,
which can be customed by user.


@yeyun,

I have not tried unbound yet, but thanks for the information, I will leave it
to another Archers for trying it.

NSCD, yes I *knew* it, and I rather not to talk about it. wink


- - -

[1] In conclusion, I can say that rescached is a very lite version of pdnsd,
where it keep fast, simple configuration, and minimal resources as possible.

Offline

#8 2010-11-24 07:14:32

ms
Member
From: Bandung, Indonesia
Registered: 2010-07-28
Posts: 68
Website

Re: rescached - yet another DNS/resolver cache daemon

This is an update to rescached.

There is a new option for a new update: cache.mode (in /etc/rescached/rescached.cfg).

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 will be replaced with a new one.

In non-technical explanation, you do not need to worry again about the problem that I mention above, rescached will handle it automatically. But, there is a consequence: old cache file does not work anymore because the change in cache format file.

A new update is already in AUR.

Thanks,

ms

Last edited by ms (2010-11-24 07:17:23)

Offline

#9 2011-05-22 11:55:38

herve18
Member
Registered: 2010-12-02
Posts: 5

Re: rescached - yet another DNS/resolver cache daemon

Hi, I used rescached for about a month and I was glad because I could still surf the Web while downloading at full speed, though I'm on a asthmatic ADSL line.

But I was getting strange behaviour lately: there was several seconds before pacman downloaded a package list from a mirror (I tried several ones), surfing was stalled while downloading, etc.

Now I've installed dnsmaq and it works out of the box. And then I can surf without even noticing I am downloading at the same time. I still need to "fix" those f*cking OpenDNS servers that reply with their own website on unknown addresses.

Thanks anyway for rescached solving that long-time issue in the first place.

Offline

#10 2011-05-23 07:40:10

essence-of-foo
Member
Registered: 2008-07-12
Posts: 63

Re: rescached - yet another DNS/resolver cache daemon

I've been using it for a few days and it's really nice smile

For unknown reasons some DNS lookups fail (which is probably not the fault of rescached). Whenever this happens, I need to stop rescached, edit/delete the cache file and start it again.

Therefore I propose the following feature: Introduce an articifial TLD like *.new which will force rescached to refresh the domain that's written before .new

example.org --> unreachable
example.org.new --> let rescached check the domain again and return the result

Last edited by essence-of-foo (2011-05-23 07:42:26)

Offline

#11 2011-05-23 15:02:23

ms
Member
From: Bandung, Indonesia
Registered: 2010-07-28
Posts: 68
Website

Re: rescached - yet another DNS/resolver cache daemon

@herve18, @essence-of-foo,

Not trying to be biased here, I have been using the same rescached source, even build and use the same package from AUR, and cannot recall the problem that you had. But, I will try to make more robust test and double check the code next time. Like someone said, network program is a hell of beast, you cannot predict how others use their network.

@essence-of-foo, I can see your point. Technically, if rescached fail at querying to DNS server (i.e: server unreachable or time-out) it will returned nothing. It will just removed from queue and waiting for the next query from client. Your application will see this as normal time-out. Adding a new TLD will just make a lot of work (checking, parsing, etc; if you know what I mean).


Thanks for trying it anyway.

PS: This comment remind me to add IPv6 support to rescached, which I planned to finished before June 8, 2011. I hope I can make it in time.

Offline

#12 2011-05-24 02:32:54

kofrad
Member
From: South Florida, USA
Registered: 2011-05-15
Posts: 45

Re: rescached - yet another DNS/resolver cache daemon

Just installed this and got it running, so far everything looks great. My quick little benchmark saw dns lookup times from 35->3 and 136->3 for microsoft.com and epcot.com. I think the feature that sold me over on pdnsd was the way the cache will purge all entries less than a certain threshold once it fills. I'm a little uncertain what optimum values would be for those fields but I'm using 100,000/25 for the max/threshold, if anyone wants to get a collection of config setups going. I haven't had time to test this on a day-to-day basis yet, but everything seems to be working fine with no errors so far. Great work, would love to see continued development on this!


Desktop: Arch Linux | AMD Athlon 64 X2 Dual Core 5000+ | 3GB RAM | GeForce 6800 XT 512MB | 1TB+
Audio Studio: XP SP3 | Intel Pentium 4 3GHz Prescott | 1GB DDR | GeForce 6800 128MB | 120GB

Offline

#13 2012-12-07 12:35:39

Thorsten Reinbold
Member
From: Germany
Registered: 2011-12-06
Posts: 314

Re: rescached - yet another DNS/resolver cache daemon

Could it be that rescached isn't compatible with up-to-date Arch Systems using systemd?

I get this, when trying to start:

sudo /usr/sbin/rcrescached start
/usr/sbin/rcrescached: Line 3: /etc/rc.conf: File or Directory not found
/usr/sbin/rcrescached: Line 4: /etc/rc.d/functions: File or Directory not found
/usr/sbin/rcrescached: Line 13: stat_busy: Command not found.
/usr/sbin/rcrescached: Line 18: add_daemon: Command not found.
/usr/sbin/rcrescached: Line 19: stat_done: Command not found.

Offline

#14 2012-12-07 20:34:38

ms
Member
From: Bandung, Indonesia
Registered: 2010-07-28
Posts: 68
Website

Re: rescached - yet another DNS/resolver cache daemon

> Could it be that rescached isn't compatible with up-to-date Arch Systems using systemd?

Yes, sorry for that. I don't have time to update the source yet.

For temporary solution you can run it manually by executing /sbin/rescached /etc/rescached/rescached.cfg.

Offline

#15 2013-01-06 21:12:49

olace
Member
Registered: 2008-02-27
Posts: 8

Re: rescached - yet another DNS/resolver cache daemon

Seems to work nice without systemd, but I got this:

[vos::DNSQuery] extract_rr: (twitter.com) Record type '41' is not handle yet!

Offline

#16 2014-12-18 20:06:27

ms
Member
From: Bandung, Indonesia
Registered: 2010-07-28
Posts: 68
Website

Re: rescached - yet another DNS/resolver cache daemon

So, four years has passed.

I just got spare time and fix the program. Many major improvements,

  • Fix memory leaks.

  • Support DNS record type 28 (AAAA or IPv6 for address).

  • Support reading and server hostname in /etc/hosts.

TODO:

  • blocking ads using hostname.

Any feedbacks will be really appreciate. Thank you!

Offline

#17 2014-12-20 10:44:00

ms
Member
From: Bandung, Indonesia
Registered: 2010-07-28
Posts: 68
Website

Re: rescached - yet another DNS/resolver cache daemon

New feature: blocking ads using host name.

Ads list provided by http://pgl.yoyo.org.

Offline

#18 2015-07-05 23:46:24

ms
Member
From: Bandung, Indonesia
Registered: 2010-07-28
Posts: 68
Website

Re: rescached - yet another DNS/resolver cache daemon

New features:

* Using TCP to connect to parent server. This is useful if your ISP block DNS connection (port 53) but forgot to block TCP connection (like my ISP).

If your ISP filtering your traffic (blocking porn, etc) by DNS, or not allowing public DNS, you can try to request using TCP to public DNS server using dig,

$ dig @8.8.8.8 +tcp www.reddit.com

If its works, use rescached as proxy between your computer and public DNS.

* Update hosts ads.
* Fixes on TCP request.
* Ads that being blocked now will be showed in log as "ads blocked" instead of "cached".

TODO:
* Statistics: show how many bytes that you save when using rescached.

Last edited by ms (2015-07-18 23:31:40)

Offline

Board footer

Powered by FluxBB