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.
- A records
- CNAME records
- Any type of Pi-hole instance
- Cloudflare API Readonly Token
- Pi-hole instance
To create a CloudFlare API token for your DNS zone go to https://dash.cloudflare.com/profile/api-tokens and follow these steps:
- Click Create Token
- Select Create Custom Token
- Provide the token a name, for example,
example.com-dns-zone-readonly
- Grant the token the following permissions:
- Zone - DNS - Read
- Set the zone resources to:
- Include - Specific Zone -
example.com
- Include - Specific Zone -
- Complete the wizard and use the generated token at the
CLOUDFLARE_API_TOKEN
variable for the container
Parameter | Description | Default | Type | Required |
---|---|---|---|---|
CLOUDFLARE_API_TOKEN | Cloudflare API Token | change_me | string | Yes |
CLOUDFLARE_DOMAIN | Cloudflare Domain | example.com | string | Yes |
EXCLUDE_PROXIED_RECORDS | Exclude Proxied Records | yes | string | Yes |
PIHOLE_HOST | Pi-hole hostname/IP | 123.123.123.123 | string | Yes |
PIHOLE_PORT | Pi-hole port | 80 | integer | Yes |
USE_HTTPS | http/https for pihole | no | string | Yes |
PIHOLE_PASSWORD | Pi-hole password | change_me | string | Yes |
RUN_EVERY | Run very x minute | 5 | integer | Yes |
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
This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details