Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Once DHCP is enabled through environment variables, it can't be disabled #1688

Open
6 tasks done
hugoduraes opened this issue Feb 10, 2025 · 5 comments
Open
6 tasks done

Comments

@hugoduraes
Copy link

hugoduraes commented Feb 10, 2025

This is a: Bug

Details

Once DHCP is enabled through environment variables, it can't be disabled. This happens because the DHCP setup is only executed when the DHCP_ACTIVE environment variable is set to true. Source code:

[[ -n "${DHCP_ACTIVE}" && ${DHCP_ACTIVE} == "true" ]] && echo "Setting DHCP server" && setup_FTL_dhcp

Related Issues

  • I have searched this repository/Pi-hole forums for existing issues and pull requests that look similar

How to reproduce the issue

  1. Environment data
  • Operating System: Raspbian
  • Hardware: RasPi 4B
  • Kernel Architecture:
  • Docker Install Info and version:
    • Software source: official docker-ce
    • Supplimentary Software:
  • Hardware architecture:
  1. docker-compose.yml
services:
  pihole:
    container_name: pihole
    image: pihole/pihole:latest
    environment:
      TZ: "Europe/Lisbon"
      WEBPASSWORD: "** REDACTED **"
      FTLCONF_LOCAL_IPV4: "192.168.10.4"
      FTLCONF_PRIVACYLEVEL: 0
      FTLCONF_MAXDBDAYS: 90
      FTLCONF_BLOCK_ICLOUD_PR: "false"
      PIHOLE_DNS_: "1.1.1.2;1.0.0.2;2606:4700:4700::1112;2606:4700:4700::1002"
      DNSSEC: "true"
      DNS_BOGUS_PRIV: "true"
      DNS_FQDN_REQUIRED: "true"
      DHCP_ACTIVE: "false"
      DHCP_START: ""
      DHCP_END: ""
      DHCP_ROUTER: ""
      DHCP_LEASETIME: 6
      PIHOLE_DOMAIN: "home"
      DNSMASQ_LISTENING: "all"
    # Volumes store your data between container upgrades
    volumes:
      - './etc-pihole:/etc/pihole'
      - './etc-dnsmasq.d:/etc/dnsmasq.d'
    cap_add:
      - NET_ADMIN
    restart: unless-stopped
    network_mode: "host"
  1. any additional info to help reproduce

Edit docker-compose.yml and enable DHCP by setting DHCP_ACTIVE to true and DHCP_START, DHCP_END and DHCP_ROUTER with the necessary values; run docker compose up -d. The Pi-hole UI should show that DHCP is enabled.
Then, edit docker-compose.yml again and disable DHCP by setting DHCP_ACTIVE to false; run docker compose up -d. The Pi-hole UI still shows that DHCP is enabled.

These common fixes didn't work for my issue

  • I have tried removing/destroying my container, and re-creating a new container
  • I have tried fresh volume data by backing up and moving/removing the old volume data
  • I have tried running the stock docker run example(s) in the readme (removing any customizations I added)
  • I have tried a newer or older version of Docker Pi-hole (depending what version the issue started in for me)
  • I have tried running without my volume data mounts to eliminate volumes as the cause

If the above debugging / fixes revealed any new information note it here.
Add any other debugging steps you've taken or theories on root cause that may help.

@hugoduraes hugoduraes mentioned this issue Feb 10, 2025
6 tasks
@yubiuser
Copy link
Member

Thanks for your report. This is clearly a bug. While the fix would be easy (mainly remove the ${DHCP_ACTIVE} == "true" requirement`) I don't think there will be a fix: we're really close to release Pi-holve v6 which will have a completely re-designed docker container and startup implementation. From a brief look, this bug is not present there.

@hugoduraes
Copy link
Author

hugoduraes commented Feb 10, 2025

Makes sense. I noticed that too, as I've opened a PR based from main branch and only then noticed that development branch didn't have this logic.

As a workaround, setting DHCP_ACTIVE to true and not setting any of the mandatory settings (DHCP_RANGE_START, DHCP_RANGE_END or DHCP_ROUTER), produces the desired effect of disabling DHCP.

@PromoFaux
Copy link
Member

Yeah, this kind of thing was something that annoy(ed/s) me with the current v5 container. It used to trip me up all the time when adding various FTLCONF_DEBUG settings.

FTL V6 directly reads environment variables, so we don't have to handle every single reversion in docker land. The logic is roughly along the lines of:

  • If env var is set - use it, mark in config file that it is updated by env var and effectively treat it as read only
  • If env var is not set:
    • If setting has been marked as manually set - do nothing
    • If setting has never been touched/was previously set by env var - revert to default value

There will be links to this when we release but this does mean that some of the env vars names will have changed to their "FTL native" equivalents:

https://deploy-preview-338--pihole-docs.netlify.app/docker/upgrading/v5-v6/#dhcp-variables

@hugoduraes
Copy link
Author

hugoduraes commented Feb 10, 2025

@yubiuser @PromoFaux Looks nice! When do you expect to release the v6?

@yubiuser
Copy link
Member

There is no fixed release date. The release per-se is ready, we only need to coordinate the team to press the button and have enough developers in stand-by to fix any post-release issues quickly and handle support request. We don't want to release when noone is around.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants