DHCP with docker-compose and bridge networking

Thanks so much for this. Made this account just to thank you. I have been trying to sort the DHCP server on my pihole for ages and this really helped. Simple when you know what your doing. only thing that threw me was that the docker-file must actually be called "Dockerfile" (case sensitive)

A post was split to a new topic: SLAAC and Docker with dockered Pi-hole as DHCP server

Just wanted to say thank you! This was an exceptionally helpful article.

Since the dhcphelper container's network is configured to run in "host" mode, can it even see bridged network? ie. -s 172.31.0.100 should be invisible to the dhcp-helper docker right?

A post was split to a new topic: Can't get DHCP server to work in dockered Pi-hole

A post was split to a new topic: Docker Pi-hole DHCP conflicts with Virgin router DHCP

A post was merged into an existing topic: Do not see DHCP devices in logs

Starting with 6.0, the “dnsmasq.d” setting is disabled by default

pihole.toml says:

# Should FTL load additional dnsmasq configuration files from /etc/dnsmasq.d/?
etc_dnsmasq_d = false

Source: Etc/dnsmasq.d files

Set the parameter “etc_dnsmasq_d" in the “pihole.toml” to true and it will work in Pi-hole 6.0 too.

1 Like

In version V6, the DNS configuration "dhcp-option=option:dns-server,x.x.x.x" does not seem to be taken. I am receiving on my machines the IP address of the container to which the DHCP relay should forward the response (i.e., that of a Docker network). I have tried changing the value in the Toml file as indicated, but unfortunately this has put the Pihole container completely out of commission, and I've also tried via misc.dnsmasq_lines but the command line is not being taken into account either... Do you have any idea?

Did you enable Settings > DHCP > Advertise DNS server multiple times? Because this already sets

"dhcp-option=option:dns-server,x.x.x.x"

Hey,
I have the same problem. Pi-hole is only advertising the container's IP and not the host IP as DNS-Server.

Did you resolve the issue by now? Anythin else seems to work so far...

Ah it seems you have to set the environment variable correctly

FTLCONF_misc_etc_dnsmasq_d: 'true'

Well, I've just retested this evening, the error was very simple, a little syntax problem in the pihole.toml file. For those interested :

dnsmasq_lines = [
“dhcp-option=option:dns-server,x.x.x.x”
]

Now it's works in bridge mode with a dhcp helper container.

Note:

If you want a simpler way to set your options, add your configuration via Web Interface Settings > All settings, misc.dnsmasq_lines, one option per line:

dhcp-option=option:dns-server,x.x.x.x
dhcp-option= ...
...

Your lines won't need extra formatting (the web interface will do it for you).

1 Like

After upgrading from v5 to v6, I cannot get dhcp to work on pi-hole. On v5, I setup dhcp-helper exactly as DerFetzer instructed and it worked perfectly. When converting to v6, I started with the docker-compose template provided in the readme and customized it to best match my v5 docker-compose file, taking care to use the correct environment variables. I noted the most recent discussions on this forum in February 2025 regarding the dns settings not passing to dhcp clients. Following the readme for first time runs after converting to v6 and the advice above, I set the FTLCONF_misc_etc_dnsmasq_d: variable to true and maintained the dnsmasq.d volume from v5. I also kept the lines for dhcp-helper that DerFetzer instructed for v5.

What can I do to get dhcp working on v6? The original instructions DerFetzer provided for v5 should still work for v6, right?

I may have fixed the problem. I did a couple of ipconfig /release and /renew from a windows machine and was able to get dhcp assignments. I will monitor it over the next couple of days and report back if it didn't work.

I added an environment variable to the docker-compose file to allow multiple dnsmasq lines to be entered. I suppose you could do this from the All Settings page in pihole v6, but I feel like it would harder for me to forget what I did to fix my issue by keeping it in the docker-compose file. The lines I added included an option to set the dns-server for dhcp clients and tell the dhcp server to use a proxy. Here's what the complete line looks like:

FTLCONF_misc_dnsmasq_lines: dhcp-option=option:dns-server,192.168.x.x;dhcp-range=192.168.x.x,proxy;dhcp-proxy

I didn't touch the dhcphelper from my v5 setup. It seems to be working fine.

It sort of worked. Pihole is handing out some dhcp assignments, but not all. I'm not sure why it's behaving this way. My camera was having a hard time getting an IP earlier today, but now it has one. My phone can't get an IP now.