Increasing DNS Cache Size

Comments

8 comments

  • Avatar
    Firewalla

    The cache size we have is 1000, it should be enough since the OS side also caches these things.  But if you see things are slower, I'll be happy to get a developer on here to see if we can make it into a generic feature. 

    0
    Comment actions Permalink
  • Avatar
    Joshbowen83

    With Pi-Hole on Gold as a Docker Image, my network performance seemed much faster. However, all I want is the DNS Boost from caching. By default, I believe Pi-Hole is set at 10000 queries - which was adviced not to go beyond that limit. It looks like Firewalla has a cache size of 1500. I wasn't sure if increasing this value would have negative consequences (especially if it is per-device cache). If I could experiment with the size, where would I enter the value. I've set up a fire router configuration file with a size of 5000, but it gets reset upon reboot. So I have Cron Jobs to set it and reload DNS service at boot any help?

    0
    Comment actions Permalink
  • Avatar
    Firewalla

    If you are not experiencing issues, then best not to touch the cache entry sizes.  

    The reason is, you are essentially doing double caching (one in firewalla and one in pi-hole docker),  if these both are on the same machine, it will just waste memory.  

    0
    Comment actions Permalink
  • Avatar
    Joshbowen83

    I removed the Pi-Hole docker container since I already have NextDNS and Firewalla working in tandem doing ad blocking. Since I have a DSL internet connection, any performance boost I can get would go a long way. Minimizing DNS requests via caching would really help with my scenario. So increasing the cache size value seems more logical than running a full blown Ad Blocking server to obtain that additional caching.

    0
    Comment actions Permalink
  • Avatar
    Joshbowen83

    Also I'm sure there is a better way to accomplish this than what I have currently set up. In order to increase the cache size, I've altered a firerouter DNS configuration file - changing cache size from 1500 to 5000. I made that change using sed via a user crontab at reboot and then a delayed root crontab at reboot to restart the firerouter DNS service via systemctl. So yeah, I believe there is a better way to accomplish this than my current situation.

    0
    Comment actions Permalink
  • Avatar
    Firewalla

    Do you see/feel much difference with 5000 cache entries?  Just curious.  

    0
    Comment actions Permalink
  • Avatar
    Joshbowen83

    Not really, but I didn't want to set it to 10000 immediately since Firewalla handles the cache per device and the initial value is so low (1500) for some reason, I guess. What I did was an experiment and not ideal or permanent - which is why I'm asking for help and suggestions at Firewalla for what I'm trying to achieve instead of relying on a unusual workaround (if it even works at all).

    0
    Comment actions Permalink
  • Avatar
    Joshbowen83

    If anyone else is interested in how I increased the DNS Cache Size for Firewalla, this is what I came up with. 

    1. Create a new shell script called dns-cache-size.sh within /home/pi.
    2. Copy and paste the following into a terminal using 'nano /home/pi/dns-cache-size.sh':

    #!/bin/bash
    cd /home/pi/firerouter/etc
    for i in *.conf
    do
    sed -i 's/cache-size=1000/cache-size=10000/g' "$i"
    sed -i 's/cache-size=1500/cache-size=10000/g' "$i"
    done

    - Save it with Ctrl-X

    3. Now Make it executable:
    chmod +x /home/pi/dns-cache-size.sh

    4. Edit Crontab by doing the following:
    crontab -e

    Then enter,

    @reboot /home/pi/dns-cache-size.sh

    5. Create a crontab using root (which has permissions to use systemctl)
    sudo su
    crontab -e 

    Enter the following:

    @reboot sleep 60 && systemctl restart firerouter_dns.service

    6. Finally, reboot Firewalla using the mobile app.

    Comments and suggestions welcome.

     

    0
    Comment actions Permalink

Please sign in to leave a comment.