Running the latest dhcpd package, dhcpd-6.0.20170207, on -current Configured /usr/local/etc/dhcpd.conf. Enabled in rc.conf. Ran service dhcpd start. It did not start. /var/log/messages shows Sep 8 12:28:27 zfs3 dhcpd: Can't open /etc/dhcpd.conf: No such file or directory Sep 8 12:28:27 zfs3 dhcpd: exiting. Easy enough, right? Change the config file location on the command line. But -c includes the text: "this option should be used only for testing database files in a non-production environment." So copy the config to /etc? No, violates pkg config rules I don't know the correct answer, but I have a couple suggestions: - make -c /usr/local/etc/dhcpd.conf the default - add a patch to change the default config file location Thanks!
Hi Michael, In the port tree 'files/dhcpd.in' is the start-stop script for the dhcpd daemon. %%PREFIX%% variable in the same 'PREFIX' variable passed during compilation. In the 'Makefile' of the the port 'MAKE_ARGS' passes default 'PREFIX' value which is '/usr/local'. Starting the daemon with the rc start-stop script executes: /usr/local/sbin/daemon -c /usr/local/etc/dhcpd.conf I'm running FreeBSD 11.0 and the latest version the ports tree and the daemon starts as its expected. No message 'this option should be used only for testing databases files in a non-production environment.' show up. I assume on FreeBSD-current there is some change in handling environment variables. I will investigate it but at the moment I will not provide patch because the port works as its expected on FreeBSD-stable. Thanks, Nikola
For clarity: The warning on -c is in the man page, not in program output.
According to the manul page: -c config-file Use an alternate configuration file, config-file. Because of the importance of using the same lease database at all times when running dhcpd in production, this option should be used only for testing database files in a non-production environment. dhcpd daemon is ported from OpenBSD. On OpenBSD by default the configuration file is /etc/dhcpd.conf. On FreeBSD by default the configuration file is /usr/local/etc/dhcpd.conf or ${PREFIX}/etc/dhcpd.conf if ${PREFIX} has different value. This parameter can be changed by 'dhcpd_flags' in /etc/rc.conf. The manual page recommends to use single configuration file because of the lease database. If using default dhcpd flags on FreeBSD it will always use ${PREFIX}/etc/dhcpd.conf and there will be no problem like mixing lease database.
Status?
The problem is that the rc.d script does not take -c /usr/local/etc/dhcpd.conf with its flags when you overwrite them in rc.conf. If you want to specify additional flags to dhcpd you will have to start them with "-c /usr/local/etc/dhcpd.conf" in rc.conf. for example: dhcpd_enable="YES" dhcpd_flags="-c /usr/local/etc/dhcpd.conf extraflagshere" I feel like the rc.d script should be extended to always give the program the following flags: "-c /usr/local/etc/dhcpd.conf" and then the extra flags should be passed by dhcpd_flags="extraflagshere". Could this be implemented? Or a similar dhcpd_interfaces="" in rc.conf as isc-dhcpd. The interfaces should just be appended to the start command. I'll take a look at this when time permits.
Created attachment 191263 [details] rc.d script patch for defining interfaces in rc.conf without overwriting default flags This should fix the overwrite of the default config file location. Interfaces can now be specified in rc.conf under "dhcpd_interfaces" and are appended to the start command.
Created attachment 191310 [details] Use PREFIX/etc/dhcpd.conf by default, dhcpd_flags="" Hi, Thanks for reporting this issue. With the following patch dhcpd will start using PREFIX/etc/dhcpd.conf by default and dhcpd_flags can be used for additional flags.
Awesome fix. Much better than mine. When can this be committed?
Comment on attachment 191263 [details] rc.d script patch for defining interfaces in rc.conf without overwriting default flags Obsolete non-maintainer submitted or approved patch.
Can someone commit this patch please?
Any updates?
A commit references this bug: Author: tz Date: Fri May 25 14:04:07 UTC 2018 New revision: 470842 URL: https://svnweb.freebsd.org/changeset/ports/470842 Log: net/dhcpd: doesn't start without discouraged -c flag Remove discouraged -c flag from rc-file. Also use PREFIX in config file PR: 222151 Submitted by: Nikola Kolev <koue@chaosophia.net> Reported by: mwlucas@michaelwlucas.com Approved by: Nikola Kolev <koue@chaosophia.net> MFC after: 2018Q2 Changes: head/net/dhcpd/Makefile head/net/dhcpd/files/dhcpd.in
Committed, thanks! :) Also i don't think that an MFH is really needed. The PR is several month old and the fix will go into the next quarterly within 3 weeks. So i don't see any need to rush. ;)
@Eugene Grosbein remove 225262 as related PR. 225262 is about net/dhcp[C]d