Adding custom records to the DNS

Hello everybody,

today I inwasted all the morning trying to figure out how to add a custom record to the DNS.

I started configuring dnsmasq, adding a host-record to /etc/dnsmasq.conf but then I realized that Omina Turris was using another dns resolver.

My problem is that I host some publicly available domains inside my home network (dynamic address), and I would like to resolve them with the local server IP.

Long story short, lurking in the forum I found some references to the hints kresd module and I wrote a small script that injects some lua code into the running resolver in order to modify the configuration.

You need to create a file named /etc/kresd/hints with the same format as /etc/hosts and the following script in /usr/sbin/kresd-fix.sh

#!/bin/bash

HACK=`mktemp -t kres_hack.XXXXXX`

echo "modules.load('hints > iterate')" > $HACK
echo "hints.config('/etc/kresd/hints')" >> $HACK

socat $HACK UNIX-CONNECT:/tmp/kresd/tty/$(pidof kresd)

rm $HACK

Than you can edit your /etc/rc.local adding /usr/sbin/kresd-fix.sh & before the exit 0 line (the last one).

Hope this may help someone else.
nolith

4 Likes