Static dhcp leases in external file

Please follow the below template, it will help us to help you!

Expected Behaviour:

Before the upgrade to v6 I used to set static ip addresses in an dnsmasq config file under /etc/dnsmasq.d/15-static-dhcp.conf containing dhcp-host lines like this
dhcp-host=aa:bb:cc:dd:ee:ff,100.100.55.3,fileserver4.my.domain.de,infinite

When changing settings I used to do:

dnsmasq --test
pihole restartdns

This is no longer recognised because dnsmasq is no longer used (if I got this right)

Hardware: Raspberry Pi 5
Software: Rasbian

Actual Behaviour:

Guess I am asking if I can replicate this behaviour in a similar way.
Where is the list under "Static DHCP configuration" in the interface saved?
pihole.toml in hosts = [ ] ?
Is the field checked before it is deployed?

What I am missing in this field is the possibility to comment. is that possible?

[Edits]: Spelling and code blocks

You can enable reading files in /etc/dnsmasq.d/ in Settings > All Settings > Misc > misc.etc_dnsmasq_d

1 Like

dnsmasq was replaced by pihole-FTL with Pi-hole v4 in 2018.
Pi-hole v4 and v5 continued to store and read configuration options at /etc/dnsmasq.d/.
This may have created conflicts, e.g. in rare cases when users required to run an additional dnsmasq instance next to Pi-hole.

Pi-hole v6 avoids those potential conflicts by storing and reading information from /etc/pihole/.

As above is calling the dnsmasq executable, that only may have worked if dnsmasq had been installed next to Pi-hole.

For both v5 and v6, you'd have to invoke that via pihole-FTL instead:

pihole-FTL dnsmasq-test

If required, you can configure Pi-hole to still include configuration information as read from /etc/dnsmasq.d/, as yubiuser has explained above.

In your specific case, you may consider to just use Pi-hole v6's Static DHCP configuration:

As you may have guessed already, the part after dhcp-host is exactly the format as accepted by Pi-hole's Static DHCP configuration.
Lines in that field would accept trailing comments, and if Pi-hole's DHCP server is active, they are validated when you hit Save&Apply.

Yes:

[dns]
(…)
[dhcp]
  (…)
  hosts = [
    "aa:bb:cc:dd:ee:fe,100.100.55.3,fileserver3.my.domain.de,infinite #comment",
    "aa:bb:cc:dd:ee:ff,100.100.55.4,fileserver4.my.domain.de,infinite #another comment"
  ] ### CHANGED, default = []
1 Like

yubiuser Bucking_Horn
Thank you very much for your answers!

Bucking_Horn
Thank you for you detailed explanation.

After I wrote my question I found the misc.etc_dnsmasq_d setting in the pihole.toml but not in the web interface, but could not change my post.

Kudos to the developers, even changing it in the .toml file, pihole noticed the change and added comments in the .toml

As above is calling the dnsmasq executable, that only may have worked if dnsmasq had been installed next to Pi-hole.

I guess I had dnsmasq installed then.

In my workflow I like to work with the files more than working in the web interface, so I would like to stick with misc.etc_dnsmasq_d=true.

pihole-FTL dnsmasq-test

is very helpful. Thank you again.

For me there is only one open question then: Is there also an equivalent to pihole restartdns?

For pihole reloadlists and pihole reloaddns the docs state

Note: This will NOT re-read any *.conf files

Should I open a new question/thread?

[Edit]: included information from docs about pihole reloadlists

Under All settings - Misc - misc.dnsmasq_lines you can add
dhcp-hostsfile=/etc/pihole/dhcp_reservations.list
or whatever file you want.
This file contains same lines as before in the dnsmasq conf-file, but without dhcp-host= at the beginning

1 Like

@roedert Thank you. This is exactly what is asked for.

DNSMASQ manpage confirms that it is re-read without a restart of the service.

-dhcp-hostsfile=
Read DHCP host information from the specified file. If a directory is given, then read all the files contained in that directory in alphabetical order. The file contains information about one host per line. The format of a line is the same as text to the right of '=' in --dhcp-host. The advantage of storing DHCP host information in this file is that it can be changed without re-starting dnsmasq: the file will be re-read when dnsmasq receives SIGHUP

So I can change the file /etc/pihole/dhcp_reservations.list, than pihole-FTL dnsmasq-test and than pihole reloadlists.

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