The WD My Cloud Pro PR2100 has an Intel Pentium N3710 quad-core 1.6 GHz processor and 4GB of DDR3 memory, which is a decent spec on which to run a NAS and some additional services. Having experienced issues with the built-in DHCP server on my Internet access provider’s router, I want to run the DHCP server for my LAN on the NAS instead.
The Busybox installation on the PR2100 includes the udhcpd server package, but the configuration and leases are wiped out each time the appliance is rebooted. To address this I’ve come up with a simple method to maintain persistence across reboots.
First create a new share on your storage which will hold your dhcpd config files, e.g. ‘dhcp’.
Next create your udhcpd.conf in the new share (/shares/dhcp) and specify the runtime options. I have provided an example below:
start 192.168.1.100 end 192.168.1.199 interface bond0 max_leases 100 remaining yes auto_time 7200 lease_file /shares/dhcp/udhcpd.leases pidfile /var/run/udhcpd.pid opt dns 22.214.171.124 opt dns 126.96.36.199 opt domain local opt router 192.168.1.1 opt subnet 255.255.255.0 opt lease 432000 static_lease 12:34:56:78:90:aa 192.168.1.100 static-host-a static_lease 12:34:56:78:90:ab 192.168.1.101 static-host-b
To make this configuration persistent across reboots you’ll need to append some commands to the startup script of a system app. For this purpose I added the ‘Internal Backups’ app which is installed to /shares/Volume_1/Nas_Prog/InternalBackups
Edit the startup script for this app (/shares/Volume_1/Nas_Prog/InternalBackups/init.sh) and add these two lines:
This will start udhcpd whenever the device is restarted and DHCP leases will remain persistent across system reboots.
To check the status of your leases you can ssh into your PR2100 (username is ‘sshd’) and use the dumpleases command. I use this command which sorts on IP address:
dumpleases -f /shares/dhcp/udhcpd.leases | tail +2 | sort -k 2
If you update the system app onto which you’ve piggy-backed the udhcpd startup commands then don’t forget to check the init script afterwards as you may need to add them again.