I’m running a Turris Omnia (OSv7.03). I would like to be able to resolve DNS for hosts on my local network, that have been assigned their IP addresses by DHCP. I know, there several other questions about this, but they’re all quite old. One of the more recent solution was “Enable DHCP clients in DNS”, which I did, and it didn’t work.
I think I have a way of doing this. But I’m trying to find the right way.
I’ve created a script, and put it at /usr/local/bin/update_dns_from_dhcp.sh
with owner and group executable set.
#!/bin/sh
$ipaddr=`grep turris /etc/hosts | cut -d ' ' -f 1`
$control_socket=`pgrep kresd`
echo "hints.config(/tmp/dhcp.leases.dynamic); hints.add('turris.mylocalsubdomain ${ipaddr}')" > socat - UNIX:/tmp/kresd/control/${control_socket}
This script updates the kresd hits via the kresd control socket using kresd’s internal LUA interpreter, which can dynamically update many aspects of the kresd config without a restart. This specific incantation will update the ‘hints’ table with the contents of DHCP leases found in /tmp/dhcp.leases.dynamic
, and also add a consistent hint to make the router itself resolvable by name.
Then, in /etc/config/dhcp
, I’ve added the following line to the config dnsmasq
section
option dhcp_script /usr/local/bin/update_dns_from_dhcp.sh
This should cause the script to be run every time a lease is added or removed.
I say ‘should’ because I’m really not sure if it will work, as I can’t find any documentation as to what options translate from /etc/config/dhcp
to dnsmasq’s actual configuration.
Also, there already exists /usr/lib/dnsmasq/dhcp-script.sh
. But looking into it, it references an environment variable $USER_DHCPSCRIPT
which it treats a a filename to be source. This seems like exactly what I want, except … Where do I set $USER_DHCPSCRIPT? Also, I’m not even sure this script is called ever by default, and I’ve no idea where to check a setting or config that would specify this.