Last active
April 3, 2024 20:08
-
-
Save zottelbeyer/c47b1a48b9c5c69796a712466e7fb71f to your computer and use it in GitHub Desktop.
ipv6 on docker-pihole
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# enable ipv6 in dockerd conf: | |
# cat /etc/docker/daemon.json | |
{ | |
"ipv6": true, | |
"fixed-cidr-v6": "2003::/64" # your ipv6. not sure if this is even necessary | |
} | |
# reload daemon conf: | |
sudo systemctl reload docker.service | |
# check it loaded okay | |
sudo systemctl status docker.service | |
# create ipv6 enabled network | |
docker network create --ipv6 --driver bridge --subnet "fd01::/64" ipv6 | |
# if you have an existing container: | |
docker network connect ipv6 pihole | |
docker network disconnect bridge pihole | |
docker restart pihole | |
# modify setupvar.conf: | |
# cat etc-pihole/setupVars.conf | grep IP | |
DHCP_IPv6=true | |
IPV4_ADDRESS=192.168.1.2 # Docker Host IP | |
IPV6_ADDRESS=fd00::1111:1111:1111:1111 # Docker Host IPv6 | |
# restart pihole dns | |
docker exec -it pihole /bin/bash -c 'pihole restartdns' | |
# updated docker run command | |
# not tested because I used portainer to modify ENV Variables! | |
docker run -d \ | |
--name pihole \ | |
-p 53:53/tcp -p 53:53/udp \ | |
-p 9000:80 \ | |
-p 9001:443 \ | |
-e TZ="Europe/Berlin" \ | |
-e ServerIPv6="fd00::1111:1111:1111:1111" \ | |
-e IPv6="true" \ | |
-v "$(pwd)/etc-pihole/:/etc/pihole/" \ | |
-v "$(pwd)/etc-dnsmasq.d/:/etc/dnsmasq.d/" \ | |
--dns=127.0.0.1 --dns=1.1.1.1 \ | |
--restart=unless-stopped \ | |
--network=ipv6 \ | |
pihole/pihole:latest | |
# To verify: | |
dig AAAA heise.de -6 @pihole | |
# from pihole -t in container | |
13:30:57 dnsmasq[1137]: query[AAAA] pihole from 172.20.0.1 | |
13:30:57 dnsmasq[1137]: /etc/pihole/local.list pihole is fd00::1111:1111:1111:1111 | |
13:30:57 dnsmasq[1137]: query[AAAA] heise.de from 172.20.0.1 | |
13:30:57 dnsmasq[1137]: cached heise.de is 2a02:2e0:3fe:1001:302:: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: "3" | |
# https://github.com/pi-hole/docker-pi-hole/blob/master/README.md | |
services: | |
pihole: | |
container_name: pihole | |
image: pihole/pihole:latest | |
# For DHCP it is recommended to remove these ports and instead add: network_mode: "host" | |
ports: | |
- "53:53/tcp" | |
- "53:53/udp" | |
- "67:67/udp" | |
- "80:80/tcp" | |
- "443:443/tcp" | |
environment: | |
TZ: 'America/Chicago' | |
# WEBPASSWORD: 'set a secure password here or it will be random' | |
IPv6: 'true' | |
ServerIPv6: 'fd00::1111:1111:1111:1111' # your dockerhost ipv6 | |
# Volumes store your data between container upgrades | |
volumes: | |
- './etc-pihole/:/etc/pihole/' | |
- './etc-dnsmasq.d/:/etc/dnsmasq.d/' | |
# run `touch ./var-log/pihole.log` first unless you like errors | |
# - './var-log/pihole.log:/var/log/pihole.log' | |
dns: | |
- 127.0.0.1 | |
- 1.1.1.1 | |
# Recommended but not required (DHCP needs NET_ADMIN) | |
# https://github.com/pi-hole/docker-pi-hole#note-on-capabilities | |
cap_add: | |
- NET_ADMIN | |
network_mode: | |
- ipv6 | |
restart: unless-stopped | |
Regarding Line 6: it is necessary 😅. Otherwise you get this error message when docker.service tries to start:
Feb 15 20:51:57 host dockerd[1335]: failed to start daemon: Error initializing network controller: IPv6 is enabled for the default bridge, but no subnet is configured. Specify an IPv6 subnet using --fixed-cidr-v6
hey, quick question, why do you need the dns option in the compose file?
dns:
- 127.0.0.1
- 1.1.1.1
hey, quick question, why do you need the dns option in the compose file?
dns:
- 127.0.0.1
- 1.1.1.1
https://github.com/pi-hole/docker-pi-hole#docker-pi-hole-v411
Just configuring according to documentation.
this worked for me from here
tried your option but pihole -d does not find ipv6 addresses
version: "3"
services:
pihole:
container_name: pihole
image: pihole/pihole:latest
network_mode: host
dns:
- 127.0.0.1
- 1.1.1.1
environment:
- TZ=${TZ}
- WEBPASSWORD=${PIHOLE_PASSWORD}
- ADMIN_EMAIL=${PIHOLE_EMAIL}
- DNS1=${PIHOLE_FIRST_DNS}
- DNS2=${PIHOLE_SECOND_DNS}
- ServerIP=${HOST_IP}
- ServerIPv6=${HOST_IPV6}
- TEMPERATUREUNIT="c"
volumes:
- './pihole/pihole/:/etc/pihole/'
- './pihole/dnsmasq/:/etc/dnsmasq.d/'
restart: unless-stopped
Note that according to the official documentation, ServerIPv6
is deprecated, and FTLCONF_REPLY_ADDR6
is replacing it.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sounds like you have to remap port 80 to something else. I do not offer support for this solution, sorry.