Page 1 of 1

Simplified DHCPD and DNS server database configuration manager

Posted: Wed Apr 17, 2019 5:59 pm
by bls
I'm one of those people that likes to know what device is at what IP address (and vice versa) on my home network. For years I've used a rudimentary script, and I recently started a project to de-rudiment it.

It's nearly ready for public consumption, but I thought I'd post this now to see what the level of interest among the Raspberry Pi community is for it. This will help me figure out how much additional polishing and testing to do in order to enable others to reliably use it.

What is it? dnm is a Python script that builds and manages a JSON-based hostname database. From that database, the appropriate DHCP and DNS (named/bind) config files are generated and installed into the system. Most importantly, for a basic implementation you don't ever need to edit /etc/hosts, or ANY of the DHCP or DNS configuration files...dnm does it all for you. You can also have IP addresses/hostnames for internet-based systems, if needed.

With dnm you can get DNS and DHCP servers running on you home network Pi in just a few minutes.

  • dnm enabls you to configure hosts easily with DHCP-assigned fixed addresses. Systems that aren't in the DHCP or DNS databases will be assigned dynamic addresses from an address pool, and their names/addresses will be added to the running DNS server (but not the databse).
  • Maintains a database for each host with IP address, hostname, MAC address, etc.
    • Database can be entered from command line (one command per line) or bulk file import
    • Database entries can be added, deleted, modified, or listed
    • Entire Database can be exported (with database config details)
    • Enables custom per-host dhcpd.conf statements (e.g., for PXE, special DNS servers, etc)
  • Builds system files from database: /etc/hosts, dhcpd.conf, and named/bind config files
  • System file creation and installation are separate steps out of an abundance of caution
  • Configure blocked DNS domain list (all names return
  • Includes complete documentation for installation and configuration of dhcpd, bind9, and this tool on Raspbian Stretch
Usage outline
  • Create and configure the Database This establishes configuration information used in the various DHCP and DNS config files
    • ndm config --create
    • ndm config --domain --subnet 192.168.1 --gateway --timeserver
    • ndm config --externaldns "" --dhcpsubnet ""
  • Add hosts
    • ndm config --import listofhosts.txt
    • ndm add --hostname mypi --macaddr nn:nn:nn:nn:nn:nn
  • List and show hosts
    • ndm list
    • ndm show mypi
    • ndm show my
  • Generate DHCP and DNS config files: ndm build
  • Install newly-built config files into the system and restart the services: ndm install
Initial release restrictions
  • Only /24 networks are supported (e.g., 192.168.1.*)
  • No IPV6 support
  • Opportunities for further data validation remain (e.g., IP addresses, etc)
I'm planning for V1 to be completed and on Github next month. Is this something that you'd find interesting? Are you interested in being an early tester/adopter?

Oh, and happy to answer your questions about it!

Re: Simplified DHCPD and DNS server database configuration manager

Posted: Wed Apr 17, 2019 6:54 pm
by Andyroo
Interesting idea.

I was using the router to hold all of this as it was simple and had an export to CSV, backup function and web front end. I then discovered that you could not restore the data to another router of the same type when mine died and EE gave me a new one with the same firmware etc. To make it worse, I could not find any serial number reference in the file despite hunting :twisted:

I use Pi-hole as both DNS and DHCP so would need to see if it would impact that before letting the family loose on the system using it - I hate supporting computers that are not ‘play’ things 8-) :lol:

Re: Simplified DHCPD and DNS server database configuration manager

Posted: Wed Apr 17, 2019 7:01 pm
by bls
@Andyroo, I've looked at PiHole, but concluded it was more than I needed, so off I went to build this. Obviously PiHole does quite a bit more than this. I tend toward lean, mean, and simple.

I didn't do any extensive research on the capability of routers to handle this, but I've never been a big fan of using my router for either DHCP or DNS. With the advent of the Pi, from my perspective there's even less reason to delegate these functions to the router.

Re: Simplified DHCPD and DNS server database configuration manager

Posted: Fri Jun 14, 2019 7:24 pm
by bls
I've posted the first release of this at From the README:

Features/capabilities include:
  • Maintain and easily update dns and dhcpd configuration files and /etc/hosts; eliminates the need to hand-edit any dns or dhcp config files
  • Easily establish your own local domain name. The easily-changed default is '.local'
  • Devices can either have statically assigned or dynamic IP addresses. Devices with dynamically assigned IP addresses are automatically added to dns when they come onto the network
  • Per-host dhcp attributes can be set. Easily configure for PXE boot, special dns servers, or other per-host specific customizations.
  • Preconfigured device IP addresses can be added, modified, listed, or deleted from the command line
  • List or export the ndm database in an ndm import format (See "Importing a network database" below)
  • Building and installing the configuration files is a two-step process to enable you to ensure their correctness and/or do custom updates if desired
  • Includes a basic blocked dns domain list feature
  • Leverages industry-proven bind9 and isc-dhcp-server for dns and dhcp services
  • Can provide dns and dhcp services for Pi-Hole (See section "Using ndm with Pi-Hole")
Enjoy if you're interested!

Re: Simplified DHCPD and DNS server database configuration manager

Posted: Fri Jun 14, 2019 7:42 pm
by epoch1970
bls wrote:
Fri Jun 14, 2019 7:24 pm
The easily-changed default is '.local'
Not the best choice on Pi where mDNS is enabled by default. ".0" (urgh) or ".lan" (dubious) perhaps?

Re: Simplified DHCPD and DNS server database configuration manager

Posted: Fri Jun 14, 2019 10:22 pm
by bls
Fair point. Will adjust. The

Code: Select all

ndm config --domain
command can be used to easily modify it as well.