The Beagle Bone Black comes loaded with a Swiss Army Knife collection of programs that run on boot. NodeRed, Cloud9, SoftAP, nginx, apache2, the list goes on. This is all fine for fresh-out-of-the-box exploration but gets very tedious when trying to extend the BeagleBone's functionality, say by installing pi-hole.

Running the pi-hole installer on a default BeagleBone Black installation (beaglebone 4.14-49-ti-r54) will result in several cryptic failures:

  • pihole-FTL[2168]: dnsmasq: cannot open or create lease file /var/run/dnsmasq.leases
  • pihole-FTL[683]: dnsmasq: illegal repeated keyword at line 9 of /etc/dnsmasq.d/SoftAp0

These errors can be resolved by changing USE_GENERATED_DNSMASQ=yes to USE_GENERATED_DNSMASQ=no in /etc/default/bb-wl18xx and commenting out L756 (echo "cache-size=2048 >> ${wfile}) and L768 (echo "dhcp-leasefile=/var/run/dnsmasq.leases" >> ${wfile} in /opt/scripts/boot/am335x_evm.sh

The BeagleBone will need rebooted after making these changes. dnsmasq should now show no errors with # service dnsmasq status. However, pihole-FTL will likely show an error: dnsmasq: cannot open or create lease file /var/lib/misc/dnsmasq.leases. This file likely exists and does not belong to the pihole user. Remove it and recreate it:

# rm /var/lib/misc/dnsmasq.leases
# touch dnsmasq.leases
# chown pihole:pihole dnsmasq.leases

Now, pi-hole will try to launch on port 80, but this in use by some of the default services on the BeagleBone. pi-hole can be modified to run on another port by changing the port number in /etc/lighttpd/external.conf: server.port = 8081 and restarting the lighttpd service.

However, if it is vital that pi-hole should run on port 80 and the other services on the BeagleBone are also necessary (they cannot be brute-force disabled), the default BeagleBone services can be moved to a different port.

First, modify nginx to run on a new port by modifying /etc/nginx/sites-enabled/default and changing all instances of 80 to a new port, say 8080.

Next, change apache2's port by editing /etc/apache2/ports.conf to Listen 8080.

The BeagleBone runs a bonescript server via nodejs. In theory, this server can be configured via /etc/default/bonescript but there are no readily available examples of this. Instead, the server can be hard-coded to avoid port 80 by editing L44 of /usr/local/lib/node_modules/bonescript/src/bonescript.js.

bonescript also commandeers port 80 via systemd. Modify /lib/systemd/system/bonescript.socket to use port 8080 as well. The bonescript service will need reloaded via # systemctl daemon-reload.

Now, restarting the pihole-FTL service should result in a functioning instance on the BeagleBone Black.


Did you just save bandwidth, reduce ads, and increase privacy because of this post? Consider saying thanks by using my Amazon Affilliate URL and help to keep this site ad & analytics free.