Skip to content

Instantly share code, notes, and snippets.

@zottelbeyer
Last active April 3, 2024 20:08
Show Gist options
  • Star 22 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save zottelbeyer/c47b1a48b9c5c69796a712466e7fb71f to your computer and use it in GitHub Desktop.
Save zottelbeyer/c47b1a48b9c5c69796a712466e7fb71f to your computer and use it in GitHub Desktop.
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
@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

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