bls
Posts: 66
Joined: Mon Oct 22, 2018 11:25 pm

Simplified DHCPD and DNS server database configuration manager

Wed Apr 17, 2019 5:59 pm

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.

Features
  • 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 127.0.0.1)
  • 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 yourdomain.com --subnet 192.168.1 --gateway 192.168.1.1 --timeserver 192.168.1.1
    • ndm config --externaldns "1.1.1.1 1.0.0.1" --dhcpsubnet "192.168.1.128 192.168.1.256"
  • Add hosts
    • ndm config --import listofhosts.txt
    • ndm add 192.168.1.2 --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!

Andyroo
Posts: 1967
Joined: Sat Jun 16, 2018 12:49 am
Location: Lincs U.K.

Re: Simplified DHCPD and DNS server database configuration manager

Wed Apr 17, 2019 6:54 pm

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:
Need Pi spray - these things are breeding in my house...

bls
Posts: 66
Joined: Mon Oct 22, 2018 11:25 pm

Re: Simplified DHCPD and DNS server database configuration manager

Wed Apr 17, 2019 7:01 pm

@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.

Return to “Networking and servers”