Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

disabling domain caching #227

Open
5cat opened this issue May 24, 2022 · 0 comments
Open

disabling domain caching #227

5cat opened this issue May 24, 2022 · 0 comments

Comments

@5cat
Copy link

5cat commented May 24, 2022

My goal is to disable the domain caching because I'm using pihole just for dns filtering and custom dns record. I have another recursive dns resolver with caching built in so i dont need the pihole caching, it is just causing website to not load.

Based on this page, I can either

  1. edit the /etc/dnsmasq.d/01-pihole.conf file
  2. edit the /etc/pihole/setupVars.conf file and restart pihole via phiole -r
    The second is not an option since pihole -r does not run in docker, running it will give Function not supported in Docker images.

Here is my attempts
I already have persistent volume for /etc/pihole so i added the CACHE_SIZE in the /etc/pihole/setupVars.conf, restarted the deployment and nothing changed. the cache size is still 1k.

I tried to add cache-size=0 value to the .Values.dnsmasq.customSettings but it gives an error since i guess no duplicate values are allowed in /etc/dnsmasq.d based on this 6 year old reddit reply.

I tried to do something naughty by mounting the /etc/dnsmasq.d/01-pihole.conf as a configMap using the following values.yaml

extraVolumeMounts:
  pihole-01-dnsmasq:
    mountPath: /etc/dnsmasq.d/01-pihole.conf
    subPath: 01-pihole.conf

extraVolumes:
  pihole-01-dnsmasq:
    configMap:
      defaultMode: 420
      name: pihole-01-dnsmasq

with

apiVersion: v1
kind: ConfigMap
metadata:
  name: pihole-01-dnsmasq 
data:
  01-pihole.conf: |
    # Pi-hole: A black hole for Internet advertisements
    # (c) 2017 Pi-hole, LLC (https://pi-hole.net)
    # Network-wide ad blocking via your own hardware.
    #
    # Dnsmasq config for Pi-hole's FTLDNS
    #
    # This file is copyright under the latest version of the EUPL.
    # Please see LICENSE file for your rights under this license.

    ###############################################################################
    #      FILE AUTOMATICALLY POPULATED BY PI-HOLE INSTALL/UPDATE PROCEDURE.      #
    # ANY CHANGES MADE TO THIS FILE AFTER INSTALL WILL BE LOST ON THE NEXT UPDATE #
    #                                                                             #
    #        IF YOU WISH TO CHANGE THE UPSTREAM SERVERS, CHANGE THEM IN:          #
    #                      /etc/pihole/setupVars.conf                             #
    #                                                                             #
    #        ANY OTHER CHANGES SHOULD BE MADE IN A SEPARATE CONFIG FILE           #
    #                    WITHIN /etc/dnsmasq.d/yourname.conf                      #
    ###############################################################################

    addn-hosts=/etc/pihole/local.list
    addn-hosts=/etc/pihole/custom.list


    localise-queries


    no-resolv



    cache-size=0

    log-queries
    log-facility=/var/log/pihole.log

    log-async
    server=192.168.100.3
    interface=eth0

which did not work since it looks like the file is autogenerated and pihole seems to delete the 01-pihole.conf to regenerate it because i got the following error in the logs

 ::: Starting docker specific checks & setup for docker pihole/pihole

  [i] Installing configs from /etc/.pihole...
  [i] Existing dnsmasq.conf found... it is not a Pi-hole file, leaving alone!
install: cannot remove '/etc/dnsmasq.d/01-pihole.conf': Device or resource busy
  [i] Installing /etc/dnsmasq.d/01-pihole.conf...[cont-init.d] 20-start.sh: exited 1.

I thought of setting the max-cache-ttl=0 in the .Values.dnsmasq.customSettings but that did not work the pihole process kept restarting in the logs

Stopping pihole-FTL
pihole-FTL: no process found
Starting pihole-FTL (no-daemon) as pihole

so i sat that to 1 meaning each dns record will live for one second .

dnsmasq:
  customSettings:
    - max-cache-ttl=1

I dont know what are the performance implication of this and i dont think this is the best way to disable the cache ( it is only enabled for one second here).

The only hacky solution that worked is

kubectl exec -n network -it $(kubectl get pod -l app=pihole -n network -o jsonpath='{.items[0].metadata.name}') -- bash -c "sed -i 's/cache-size=.*$/cache-size=0/' /etc/dnsmasq.d/01-pihole.conf && pihole restartdns"

where network is the namespace and app=pihole i guess is the app label i gave when i installed it via helm.

Is there another option to actually disable dns caching in a kubernetic way?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant