Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ipv6 on docker-pihole
# 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::
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
@tbuchmann
Copy link

tbuchmann commented Jan 25, 2021

Thank you very much for your efforts, i tried to get IPv6 running on my Raspberry PI with OpenMediaVault and PI Hole running in docker via portainer. However, if I try to:

docker network connect ipv6 pihole

I get the following error message:
"Error response from daemon: driver failed programming external connectivity on endpoint PI-Hole (...): Error starting userland proxy: listen tcp4 0.0.0.0:80: bind: address already in use"

I followed this guide to setup PI Hole on OpenMediaVault:
https://www.wundertech.net/how-to-set-up-pi-hole-on-openmediavault/

Unfortunately i can not disable IPv6 on my DSL Router, so I have to get it running somehow...

@zottelbeyer
Copy link
Author

zottelbeyer commented Jan 25, 2021

Sounds like you have to remap port 80 to something else. I do not offer support for this solution, sorry.

@anthony-wang
Copy link

anthony-wang commented Feb 15, 2021

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

@theodormanolescu
Copy link

theodormanolescu commented Mar 25, 2021

hey, quick question, why do you need the dns option in the compose file?
dns:
- 127.0.0.1
- 1.1.1.1

@zottelbeyer
Copy link
Author

zottelbeyer commented Mar 25, 2021

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.

@theodormanolescu
Copy link

theodormanolescu commented Mar 25, 2021

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

@Alexivia
Copy link

Alexivia commented Dec 28, 2021

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