QNAP custom dhcpd config file

In some network I wanted to use QNAP nas (QTS 4.3.4 x64) also as DHCP server, but with my own config file. I needed static bindings and special config with cookie for Smart-UPS RT 10000 XL (which I already mentioned here).
First option was to use some App from AppCenter like DNSMasq (not seen that app? 🙂 You can use alternative repo like https://www.qnapclub.eu/pl/repo/xml – maybe I’ll write something more about that some day), but in my case the default volume is encrypted. As long as I don’t enter password manually after restart or a power failure apps won’t get loaded, so network is dead without DHCP server.
Some solution is to make special not encrypted volume only with that app – but unfortunately most apps does not support volume migration (some other time I will write something more about how to enable this option).
The third solution is to use system dhcp server which is ISC DHCP. It is loaded even when main volume is not mounted. But how to provide custom config premanently?

First of all we need to enable dhcp server in Network & Virtual switch app. In my case br0 interface was used. I propose to configure as small IP range as possible in case if some client succeed to connect before we replace config (just one IP would be fine). Then we put our config file in


For my UPS it was something like:

ddns-update-style none;
get-lease-hostnames true;
default-lease-time 7200;                                                                                                                                                     
max-lease-time 7200;
log-facility local7;
ping-check false;
option apc-token code 43 = string;

subnet netmask {
    option domain-name "domain.org";
    option domain-name-servers,;
    option routers;
    option subnet-mask;
    option broadcast-address;

#some static host
host hsot1 {
   hardware ethernet 04:14:a6:c9:66:78;

#Smart-UPS RT 10000 XL  with AP9619 card 
host ups {
   hardware ethernet 00:ca:a7:62:37:64;
   #cookie needed to get things work
   option apc-token 01:04:31:41:50:43;

Then we create




/bin/grep -q custom_config /etc/dhcpd_br0.conf || \
    ( cp -f /etc/config/dhcpd_br0.conf /etc/dhcpd_br0.conf && \
    kill `cat /mnt/ext/opt/netmgr/api/core/dhcpdLink/br0.pid` )

That script checks if the current config file is ours. If not it replaces the file and kills dhcpd server. QTS has some kind of watchdog mechanism so we don’t need to bother to start it again (ISC DHCP does not support config reload with signals so more elegant way is not possible 🙁 ). Please remember to set correct permissions by

chmod 700 /etc/config/dhcpd_check

Last thing to do is to add our script to cron by editing


and adding

* * * * * /etc/config/./dhcpd_check

Not very elegant solution, but works 🙂

UPS on macOS Sierra 10.12 with snmp problem

I’m using Smart-UPS RT 10000 XL on my network and wanted to use it also with my iMac runing macOS Sierra 10.12. An AP9619 card enables user to monitor UPS status with SNMP. For that purpose I installed apcupsd package using Homebrew:

brew install apcupsd

Configuration file is located at:


and there was a need to change some things:


Everything seemed to work, but after some time I noticed that power failure didn’t shut down my iMac.
I noticed that after reboot status check

/usr/local/Cellar/apcupsd/3.14.14/sbin/apcaccess status

resulted in something like that:

APC      : 001,018,0459
DATE     : 2018-02-03 13:27:16 +0100  
HOSTNAME : My-iMac.local
VERSION  : 3.14.14 (31 May 2016) darwin
UPSNAME  : My-iMac.local
CABLE    : Ethernet Link
UPSMODE  : Stand Alone
STARTTIME: 2018-02-03 13:08:14 +0100  
MBATTCHG : 5 Percent
MINTIMEL : 3 Minutes
MAXTIME  : 0 Seconds
TONBATT  : 0 Seconds
CUMONBATT: 0 Seconds
STATFLAG : 0x05000000
END APC  : 2018-02-03 13:27:44 +0100

I seemed that UPS was not visible. After restarting service

sudo sudo launchctl stop org.apcupsd.apcupsd
sudo sudo launchctl start org.apcupsd.apcupsd

everything was going back to normal:

APC      : 001,046,1075
DATE     : 2018-02-03 13:45:42 +0100  
HOSTNAME : My-iMac.local
VERSION  : 3.14.14 (31 May 2016) darwin
CABLE    : Ethernet Link
UPSMODE  : Stand Alone
STARTTIME: 2018-02-03 13:45:39 +0100  
MODEL    : Smart-UPS RT 10000 XL
LINEV    : 243.0 Volts
LOADPCT  : 15.0 Percent
BCHARGE  : 100.0 Percent
TIMELEFT : 114.0 Minutes
MBATTCHG : 5 Percent
MINTIMEL : 3 Minutes
MAXTIME  : 0 Seconds
MAXLINEV : 243.0 Volts
MINLINEV : 236.0 Volts
OUTPUTV  : 229.0 Volts
SENSE    : Unknown
DWAKE    : 0 Seconds
DSHUTD   : 20 Seconds
DLOWBATT : 2 Minutes
LOTRANS  : 196.0 Volts
HITRANS  : 253.0 Volts
RETPCT   : 0.0 Percent
ITEMP    : 25.0 C
ALARMDEL : 5 Seconds
BATTV    : 218.0 Volts
LINEFREQ : 49.0 Hz
LASTXFER : Unacceptable line voltage changes
TONBATT  : 0 Seconds
CUMONBATT: 0 Seconds
STESTI   : 336
STATFLAG : 0x05000008
MANDATE  : 07/11/07
SERIALNO : IS000000000
BATTDATE : 07/11/07
NOMOUTV  : 230 Volts
FIRMWARE : 476.17.W
END APC  : 2018-02-03 13:45:45 +0100 

After some debugging I realized that daemon is started before network was ready (don’t know if it is a brew package problem or my configuration is specific).
Turned out that apcupsd wasn’t able to use network connection initialized after it’s start. My solution is not very elegant, but fully satisfying – addition of some delay

/bin/sleep  180

in the second line of


was sufficient.