Pihole resolving its ip as internal IP

So, im using the tutorial/docs from DerFetzer on this link DHCP with docker-compose and bridge networking

I ended-up wiht a little different docker-compose running in a raspeberry pi 4 file as follow:

version: "3.7"

########################### NETWORKS
networks:
  t2_proxy:
    external:
      name: t2_proxy
  default:
    driver: bridge
  dhcp_relay_net:
    ipam:
      config:
        - subnet: 172.32.0.0/16

########################### SERVICES
services:
  pihole:
    #image: pihole/pihole:latest
    build: dockerfiles/pihole-unbound
    container_name: pihole
    hostname: pihole
    domainname: $PIHOLE_NAME.$DOMAINNAME
    ports:
      - "53:53/tcp"
      - "53:53/udp"
      - "8181:80/tcp"
    restart: unless-stopped
    cap_add:
        - NET_ADMIN
    environment:
      ServerIP: 192.168.0.10
      WEBPASSWORD: $PWD
      DNS1: 127.0.0.1#5335
      DNS2: 127.0.0.1#5335
      DNSMASQ_LISTENING: all
    volumes:
      - '$DOCKERDIR/pihole/pihole_data:/etc/pihole/'
      - '$DOCKERDIR/pihole/dnsmasq.d:/etc/dnsmasq.d/'
    depends_on:
      - dhcphelper
    networks:
      dhcp_relay_net:
        ipv4_address: 172.32.0.100
      t2_proxy: {}
    labels:
      - "traefik.enable=true"

      #sinkhole for port 80
      - "traefik.http.routers.pihole80.rule=Host(`pihole.$DOMAINNAME`)" 
      - "traefik.http.routers.pihole80.service=pihole80@docker"
      - "traefik.http.routers.pihole80.entrypoints=http"
      - "traefik.http.services.pihole80.loadbalancer.server.port=80"
      #sinkhole for port 443 by IP
      - "traefik.http.routers.pihole443.rule=Host(`pihole.$DOMAINNAME`)"
      - "traefik.http.routers.pihole443.service=pihole443@docker"
      - "traefik.http.routers.pihole443.entrypoints=https"
      - "traefik.http.routers.pihole443.tls=true"
      - "traefik.http.services.pihole443.loadbalancer.server.port=80"
      - "traefik.http.routers.pihole443.middlewares=chain-oauth@file" # Google OAuth 2.0
      - "traefik.http.routers.pihole443.middlewares=admin-pihole@file" #addprefixadmin

  dhcphelper:
    build: dockerfiles/dhcp-helper
    container_name: dhcphelper
    restart: unless-stopped
    network_mode: "host"
    command: -s 172.32.0.100
    cap_add:
      - NET_ADMIN

Actual Behaviour:

Should be possible to ping and acess my pihole from the url https://pihole.mydomain

Actual Behaviour:

When i ping pihole.mydomain from any of my computer client I got the internal local ip address from pihole this means 172.32.0.100 so, I cant access the pihole using DNS.

But when I do 192.168.0.10:8181 it does show everything and works really well, a part from that, the pihole is working fine with traefik. Note the Traefik and Pihole are in the same Raspberry PI.

Debug Token:

s5zvov038n

You should be able to access Pi-hole via pi.hole, as that's the name it defines for itself.

It seems you've based your additional custom hostname configuration for pihole.mydomain purely on docker-compose options:

I personally haven't used any of these options, but it seems you've defined domainname as an FQDN, while my guess is that should just hold the domain portion (assuming that combining hostname and domainname would produce your FQDN - docker-compose spec is not overly verbose in that regard).

I further suspect that this somehow invites Docker's own internal DNS to take over and thus answer an internal Docker IP.

I'd start trouble-shooting by removing those three lines completely.

If you want to add a different name for your Pi-hole, try to do so by creating the appropriate Local DNS Records.

Thank you so much!

I Just commented the hostname and domainname. And now it's working, but the funny part is the name showed on the pihole its just a random one now, but no problem.

image

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.