Sign inSign up

fire1ce/pihole-cloudflare-dns-sync

By fire1ce

•Updated over 3 years ago

Lightweight Container to be used in conjunction with a Pi-hole instance to sync the DNS records of C

Image
2

10K+

fire1ce/pihole-cloudflare-dns-sync repository overview

⁠pihole-cloudflare-dns-sync

Build License: GPL v3 Docker Pulls Docker Stars https://3os.org Contribution is Welcome

⁠Description

Lightweight Container image based on python:3.9.13-alpine⁠ to be used in conjunction with a Pi-hole⁠ instance to sync the DNS records from Cloudflare DNS Service⁠ to Pi-hole local DNS.

⁠Supports
  • A records
  • CNAME records
  • Any type of Pi-hole instance

⁠Requirements

  • Cloudflare API Readonly Token
  • Pi-hole instance
⁠Creating a Cloudflare API token

To create a CloudFlare API token for your DNS zone go to https://dash.cloudflare.com/profile/api-tokens⁠ and follow these steps:

  1. Click Create Token
  2. Select Create Custom Token
  3. Provide the token a name, for example, example.com-dns-zone-readonly
  4. Grant the token the following permissions:
    • Zone - DNS - Read
  5. Set the zone resources to:
    • Include - Specific Zone - example.com
  6. Complete the wizard and use the generated token at the CLOUDFLARE_API_TOKEN variable for the container

⁠Parameters

ParameterDescriptionDefaultTypeRequired
CLOUDFLARE_API_TOKENCloudflare API Tokenchange_mestringYes
CLOUDFLARE_DOMAINCloudflare Domainexample.comstringYes
EXCLUDE_PROXIED_RECORDSExclude Proxied RecordsyesstringYes
PIHOLE_HOSTPi-hole hostname/IP123.123.123.123stringYes
PIHOLE_PORTPi-hole port80integerYes
USE_HTTPShttp/https for piholenostringYes
PIHOLE_PASSWORDPi-hole passwordchange_mestringYes
RUN_EVERYRun very x minute5integerYes

⁠Usage

Docker run example:

docker run -d \
  --name pihole-cloudflare-dns-sync \
  -h pihole-cloudflare-dns-sync \
  --restart always \
  -v /etc/timezone:/etc/timezone:ro \
  -v /etc/localtime:/etc/localtime:ro \
  -e CLOUDFLARE_API_TOKEN=cloudflare_secret_dns_zone_api_token \
  -e CLOUDFLARE_DOMAIN=example.com \
  -e EXCLUDE_PROXIED_RECORDS=yes \
  -e PIHOLE_HOST=123.123.123.123 \
  -e PIHOLE_PORT=80 \
  -e USE_HTTPS=no \
  -e PIHOLE_PASSWORD=secret \
  -e RUN_EVERY=1 \
  -e PUID=1000 \
  -e PGID=1000 \
fire1ce/pihole-cloudflare-dns-sync

Docker compose example:

version: '3'

services:
  pihole-cloudflare-dns-sync:
    image: fire1ce/pihole-cloudflare-dns-sync
    container_name: pihole-cloudflare-dns-sync
    hostname: pihole-cloudflare-dns-sync
    restart: always
    network_mode: bridge
    volumes:
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    environment:
      - CLOUDFLARE_API_TOKEN=cloudflare_secret_dns_zone_api_token
      - CLOUDFLARE_DOMAIN=example.com
      - EXCLUDE_PROXIED_RECORDS=yes
      - PIHOLE_HOST=123.123.123.123
      - PIHOLE_PORT=80
      - USE_HTTPS=no
      - PIHOLE_PASSWORD=secret
      - RUN_EVERY=1
      - PUID=1000
      - PGID=1000

⁠License

This project is licensed under the GNU General Public License v3.0 - see the LICENSE⁠ file for details

Tag summary

Content type

Image

Digest

sha256:86cfedff3…

Size

24.9 MB

Last updated

over 3 years ago

docker pull fire1ce/pihole-cloudflare-dns-sync