Pihole and unbound in a container

118 Views Asked by At

I'm trying to run both Pihole and Unbound using a Docker compose, but I'm facing an issue I cannot fix. Once the containers are up, DNS queries are forwarded from Pihole to Unbound on the Pihole log. Still, the host where I'm running the containers lost its ability to make queries, e.g., If I do dig pi-hole.net on the host console I can't resolve the IP address.

mlino@PIhole-2:/# dig pi-hole.net

; <<>> DiG 9.16.44-Debian <<>> pi-hole.net
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 58616
;; flags: qr rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0
;; WARNING: recursion requested but not available

;; QUESTION SECTION:
;pi-hole.net.                   IN      A

;; Query time: 3999 msec
;; SERVER: 127.0.0.11#53(127.0.0.11)
;; WHEN: Fri Feb 09 19:02:24 -03 2024
;; MSG SIZE  rcvd: 29

My docker-compose.yaml looks like the following:

pihole:
    container_name: pihole
    image: pihole/pihole:latest
    hostname: PIhole-2
    depends_on:
      - unbound
    ports:
      - "53:53/tcp"
      - "53:53/udp"
      - "80:80/tcp"
      - "443:443/tcp"
    environment:
      TZ: 'America/Recife'
      WEBPASSWORD: 'XXXXXXXXXXX'
      FTLCONF_LOCAL_IPV4: 172.16.65.70
      PIHOLE_DNS_: 172.21.200.3#5335
      DNSSEC: true
    dns:
      127.0.0.1
    volumes:
      - './etc-pihole:/etc/pihole'
      - './etc-dnsmasq.d:/etc/dnsmasq.d'
    restart: unless-stopped
  
  unbound:
    container_name: unbound
    image: "mvance/unbound:latest"
    hostname: unbound
    restart: unless-stopped
    ports:
      - "5335:53/tcp"
      - "5335:53/udp"
    networks:
      pihole_dns_network:
        ipv4_address: 172.21.200.3

networks:
pihole_dns_network:
    name: "pihole_dns_network"
    ipam:
      driver: default
      config:
        - subnet: 172.21.200.0/24
          gateway: 172.21.200.1
          ip_range: 172.21.200.1/24

I'm running Docker on Ubuntu 23.04, and I have turned off its DNS resolver and edited the /etc/resolv.conf manually to:

nameserver 127.0.0.1

I would appreciate any help that leads to solving this issue.

Marcio

0

There are 0 best solutions below