GithubHelp home page GithubHelp logo

pihole-unbound-redis's Introduction

Docker Compose for Pihole - Unbound - Redis Setup

About

This project is designed to support a docker compose deployment of Pihole using Unbound DNS upstream with a persistent Redis cache for Unbound.

The default configuration is tuned for performance:

  • Unbound is configured as a forwarder, see forward-records.conf
  • Unbound is configured to serve expired, min ttl = 300/max ttl = 86400, and prefetch= on

Getting Started

To run, execute the following command from the project root directory:

docker compose -f "pihole-unbound-redis-compose.yml" up -d --build

Accessing the Pihole Web UI

Access at http://{$HOSTNAME}/admin

If you are running Pihole for the first time you will need to set a password to access the Web UI.

Attach shell to the pihole container shell and run the following

pihole -a -p

Tuning

Host OS Tuning

These settings should be setup when you first get started so that Redis and Unbound behave as expected.

Run these on your host machine to update without restarting (will not persist across restart)

sudo sysctl vm.overcommit_memory=1
sudo sysctl -w net.core.wmem_max=8388608
sudo sysctl -w net.core.rmem_max=8388608

Edit to host machine sysctl.conf to persist

sudo nano /etc/sysctl.conf

vm.overcommit_memory=1
net.core.rmem_max=8388608
net.core.wmem_max=8388608

Unbound Configuration Tuning

Custom Unbound configuration can be stored at /unbound-config/custom/*.conf

Examples can be found at unbound-config/examples and will override base configuration.

Enabling Unbound DNS Remote Control

Run the following on the host machine within the project root directory:

sudo chown 1500:1500 unbound-keys

Run the following from attached shell on the unbound container:

unbound-control-setup -d /etc/unbound/keys

Create (or copy from examples directory) unbound-config/custom/remote-control.conf with the following:

remote-control:
    control-enable: yes 
    server-key-file: "/etc/unbound/keys/unbound_server.key"
    server-cert-file: "/etc/unbound/keys/unbound_server.pem"
    control-key-file: "/etc/unbound/keys/unbound_control.key"
    control-cert-file: "/etc/unbound/keys/unbound_control.pem"

Once added, restart the container for unbound for the changes to take effect.

Redis Configuration Tuning

Custom Redis configuration can be stored at /redis-config/custom/*.conf

Examples can be found at redis-config/examples and will override base configuration.

Redis Socket Communcation

Redis and Unbound communicate via unix sockets to reduce overhead

In redis.conf, sockets are configured:

unixsocket /tmp/docker/redis.sock
unixsocketperm 777

Thanks

Special thanks to crazy-max for their Unbound docker image

pihole-unbound-redis's People

Contributors

tternquist avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.