Michael & All,
Here is another update for the `unbound-dhcp-leases-bridge` code.
I believe I have copied all the processes done in `unbound-dhcp-leases-bridge`, so if I am missing a function please speak up.
Everything seems to be working A-OK (for me!). - I’ve re-written much/most of the code, - added bash functions for unbound writes & deletes to get rid of duplicate code, - and added some error (invalid) checks.
Since the code is not parsing the dhcp-leases I believe it _may_ be fast enough for lots of dhcp clients. But I have no way of knowing without your help!
I’ve written two "compare" scripts: 1) if you want to compare the old with new. This requires some updates to the script below. 2) or if want to compare `/etc/unbound/dhcp-leases.conf` plus `/etc/unbound/hosts.conf` to the unbound cache `unbound-control list_local_data`.
Static Hosts ————————————
• Static hosts still need to be parsed into unbound hosts.conf file
I am looking for help with this since I dont fully understand the "read_static_hosts" section: https://github.com/ipfire/ipfire-2.x/blob/master/config/unbound/unbound-dhcp...
- Why are the static hosts read into the "unbound-dhcp-leases-bridge" program? - Does this section write the static hosts into the the unbound `/etc/unbound/hosts.conf` file? (I dont believe it does) - Or are the static hosts for reference only?
Currently I do a quick grep search of the `/etc/unbound/hosts.conf` file for IP address and hostname in Line 142. If an IP/hostname exists in the static hosts file, then I exit.
So I think this is what the unbound-dhcp-leases-bridge does…
Hostnames with Spaces —————————————————————
• Properly handle hostnames with spaces
I remove the spaces in the hostname - yes, I have one device with this non-legit hostname
Is this OK?
=============================================================================== NOTE: Do not place this into a Production environment - only for Test environment.
• If placed into Test environment this current script will terminate "unbound-dhcp-leases-bridge". • Do not run the `dhcpEvent.sh` script and "unbound-dhcp-leases-bridge" in parallel. ===============================================================================
Once again I am looking for help, feedback, thoughts and comments!
Jon
On Dec 8, 2023, at 10:26 AM, jon jon.murphy@ipfire.org wrote:
The first script did not place A & PTR records into the unbound cache and this version does!
Once again I am looking for your feedback, thoughts and comments!
Jon
===============================================================================
NOTE: Do not place this into a Production environment - only for Test environment.
Description of Proof of Concept ———————————————————————————————
Transfers DHCP lease information to unbound DNS
• Enable DHCP On Commit/Release/Expire via dhcpd.conf (or dhcpd.conf.local) • A new (or changed or removed) dynamic/fixed lease causes Script to run • Script adds A & PTR records on Commit: • to unbound dhcp-leases.conf file • to unbound cache via "unbound-control load-data" • Script removes A & PTR records on Release or Expiry of lease
The Script ———————————
• Handles dynamic and fixed leases • Static hosts checked for duplicates • Re-enabled unbound-control local_data • unbound reloads not needed • A & PTR records survive IPFire reboot, unbound restart • no delays from difficult dhcp-leases parsing
Not completed (yet): • Static hosts still need to be parsed into unbound hosts.conf file • Properly handle hostnames with spaces • non-legit need to change to dashes or be removed (or completely dropped) • to be checked with large amount of clients • I’ve tested with 6 devices on test system and ~40 devices on production
<dhcpEvent_v15.sh.txt><dhcpd.conf.local>
NOTE: Do not place this into a Production environment. Only for Test environment.
• If placed into Test environment this current script will terminate "unbound-dhcp-leases-bridge". • Do not run the `dhcpEvent.sh` script and "unbound-dhcp-leases-bridge" in parallel.