Giter Club home page Giter Club logo

docker-pihole-dns-shim's Introduction

docker-pihole-dns-shim

Synchronise records founds through docker labels with pihole's custom dns and cname records.

How to get started

Find your secret pihole token

  • Navigate to the api tab in your pihole settings
  • Click the Show API token button
  • Copy the Raw API Token
  • Use this as PIHOLE_TOKEN

Run

cli

docker run \
  -l "pihole.custom-record=[[\"pihole-dns-shim.lan\", \"127.0.0.1\"]]" \
  -e PIHOLE_TOKEN="" \
  -e PIHOLE_API="http://pi.hole:8080/admin/api.php" \
  -e STATE_FILE="/state/pihole.state" \
  -v /var/run/docker.sock:/var/run/docker.sock:ro \
  theonlysinjin/docker-pihole-dns-shim

docker-compose.yml

services:
  pihole-dns-shim:
    container_name: "pihole-dns-shim"
    image: theonlysinjin/docker-pihole-dns-shim
    restart: unless-stopped
    labels:
      - pihole.custom-record=[["pihole-dns-shim.lan", "127.0.0.1"]]
    environment:
      PIHOLE_TOKEN: "${PIHOLE_TOKEN}"
      PIHOLE_API: "${PIHOLE_API}"
      # LOGGING_LEVEL: "DEBUG"
      # STATE_FILE: "/state/pihole.state"
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock:ro"

Label

Add records to pihole by labelling your docker containers, you can add as many labels(records) to individual containers as you need.
An example of the (json-encoded) label is as follows:

pihole.custom-record:
  - ["pihole-dns-shim.lan", "127.0.0.1"]
  - ["pihole-dns-shim.lan", "www.google.com"]

as a docker label:

"pihole.custom-record=[[\"pihole-dns-shim.lan\", \"127.0.0.1\"], [\"pihole-dns-shim.lan\", \"www.google.com\"]]"

Development

Debug

You can turn on extra logging by setting the log level to DEBUG,
Set an env variable in the container with LOGGING_LEVEL="DEBUG"

API Endpoints

Make a GET request to the following endpoints.
Replace the parts of the url that are in uppercase.

Manage A Records

Add new DNS record
http://pi.hole:8080/admin/api.php?customdns&action=add&ip=IPADDRESS&domain=DOMAIN&auth=XXX

Delete existing DNS record
http://pi.hole:8080/admin/api.php?customdns&action=delete&ip=IPADDRESS&domain=DOMAIN&auth=XXX

List existing DNS records
http://pi.hole:8080/admin/api.php?customdns&action=get&auth=XXX

Manage CNAME Records

Add new CNAME record
http://pi.hole:8080/admin/api.php?customcname&action=add&domain=DOMAIN&target=TARGET&auth=XXX

Delete existing CNAME record
http://pi.hole:8080/admin/api.php?customcname&action=delete&domain=DOMAIN&target=TARGET&auth=XXX

List existing CNAME records
http://pi.hole:8080/admin/api.php?customcname&action=get&auth=XXX

docker-pihole-dns-shim's People

Contributors

theonlysinjin avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

kitof

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.