Automatically populating DNS from DHCP static leases?

My local network uses DHCP. I’m trying to set up local names and static addresses for some well-known devices.

This appears to be a bit of a morass because it seems that most of the DNS settings only apply to dnsmasq, but the main DNS resolver is kresd (this could use some UI improvements)… however, I’ve made it work:

But only by entering all the information twice: once in the DHCP static leases page, and then I have to enter all the hostname/IP information again in the Hostnames page. (All in Luci, as none of this appears configurable in Foris.)

Am I missing some way of automatically populating DNS with the information from the static leases? It would make setting up new devices far easier.

(There’s an option in Foris to do just this, but it doesn’t seem to do anything.)

1 Like

This is done automatically, though only for ipv4 in conjunction with dnsmasq (not working with ipv6/odhcpd) , by net/resolver-conf/files/ · v3.11.2 · Turris / Turris OS / Turris OS packages · GitLab

Perhaps you could describe the symptom of what is not working as it is not so apparent from the post.

That should not be necessary.

Foris is not meant as a replacement for LuCI, there is a distinctive difference in the user type being served by each frontend respectively. That said it could be confusing at times in view of settings overlapping amongst the 2 frontends.

1 Like

Well, the symptom is as described — I enter hostname, mac address and IP address into the DHCP configuration page, and then even though the device gets assigned the correct IP address by DHCP, DNS lookups don’t resolve the hostnames to the IP address.

If this is configuring dnsmasq only, then how could I verify that kresd is forwarding requests to dnsmasq?

I am not sure whether changing dnsmasq DHCP settings in LuCI is actually invoking a reload of the resolver or just dnsmasq (and thus missing to kick off

Try from ssh cli /etc/init.d/resolver reload or /etc/init.d/resolver restart which kicks off

To my understanding it is not forwarding but the script is adding host files to kresd by parsing the config settings in dhcp

def refresh_leases(self):
        if self.__static_leases_enabled:
            self._call_kresd("hints.add_hosts('%s')" % self.__static_leases)
        if self.__dynamic_leases_enabled:
            self._call_kresd("hints.add_hosts('%s')" % self.__dynamic_leases)

I would do it differently:
Try this, for example. If you are interested in a static reservation, do the following:

Edit your file and enter information here:

@anon50890781: I’ve been rebooting to make sure that any configuration changes take effect.

@RomanHK: that doesn’t do what I want it to do. I want to configure DHCP and DNS in a single place. Editing /etc/hosts (which I’ve actually also tried, along with editing /etc/ethers) will still require me to enter the hostnames and IP addresses twice.

1 Like

I have to throw in the towel here as not being familiar with kresd. The script works as expected for unbound, i.e. only having entered static leases in LuCI. That was until having switched to odhcpd which is not supported by the script, but that is a different story then.

Well, thanks for trying anyway…

I haven’t done any customisation of my system; this is as it shipped. Is this all supposed to work out of the box? I came here from DD-WRT, where this kind of configuration is very easy.

Unfortunately, it did not work otherwise. When I have enabled DNS in Foris, a domain (lan) is required, so the result was: computer1.lan or computer2.lan

To do this all in one place, we (the users) will not do anything about it. It’s up to developers to do it.

I hope so :slight_smile:

… that dynamic script need some revision. There is another issue with format of lease files, script is complaining about it since two updates of TOS back (i did not changed anything).
Now have to use static leases for some “important” devices in my network in combination of hostname entries using Luci. And so far all of them are getting my local dns ips.
Populating DNS, … chmmm, it is a bit tricky as it is not just one place but three, to trigger it. I think i have it working with localdomain and static leases. Let me check my setup (tomorrow possibly), i will try to give more specific hints …

So here it is. Hope it helps.


  • use forwarding: no
  • disable dnssec: no
  • enable dhcp clienst in dns: yes
  • domain of dhcp clients in dns : mydomain.lan
  • enter hostname for each client names (without mydomain.lan part)
    (general settings)
  • domain required : yes
  • local server : /mydomain.lan/
  • local domains : mydomain.lan
  • dns forwarding : list-of-you-favorite-dns-servers
    (resolv and hosts files)
  • use /etc/ethers : no
  • leasefiles: /path/to/dhcp.leases
  • ignore resolve file: yes
  • ignore /etc/hosts : yes
    (static leases)
  • define entry for each “hostname” , exactly same strings without mydomain.lan string
    (advanced settings)
  • expand hosts: no
  • strict order: yes
    (DHCP Server: advanced settings )
  • dynamic dhcp : yes
  • force : yes
  • dhcp-options: “6,,”
    (advanced settings)
  • bring up on boot: yes
  • use default gateway : yes
  • use dns servers advertised by peer: no
  • use custom dns servers : list-of-your-favorite-dns-servers

And in some uci configs (dhcp,resolver) i have to check and setup static/dynamic domain parameter(and value) explicitly for each configuration block/resolver.

In Foris you can choose the suffix. It doesn’t let you choose an empty one, though. In any case, I personally don’t think leaving an empty one would be a good idea.

For me the names from DHCP just work out of the box, after clicking that single checkbox in Foris.

If you want to track down what’s wrong, you can inspect an “in-between” place: /tmp/dhcp.leases.dynamic

EDIT: well, I’ve only tested all this with “dynamic leases” actually so far.

Hosts from DHCP to DNS. Need to set static DHCP:
add to /etc/config/dhcp host

config host
option tag ‘lan’ <— tag of lan static host
option name ‘dgw’
option mac ‘00:09:b0:xx:xx:x’
option ip ‘’

and domain my config dnsmasq:
(hosts add from LuciGIU [DHCP and DNS] but without option tag ‘lan’ :frowning: )

config dnsmasq
option domainneeded ‘1’
option boguspriv ‘1’
option localise_queries ‘1’
option rebind_protection ‘1’
option rebind_localhost ‘1’
option local ‘/’
option domain ‘
option expandhosts ‘1’
option authoritative ‘1’
option readethers ‘1’
option leasefile ‘/tmp/dhcp.leases’
option resolvfile ‘/tmp/’
option port ‘0’
option localservice ‘1’
option quietdhcp ‘1’
option nonwildcard ‘1’
list interface ‘br-lan’

in /etc/dnsmasg.conf you add:
#pool for non static users

/etc/init.d/dnsmasq restart

and DNS now:

ping dgw
PING iradiow ( 56 data bytes
64 bytes from seq=0 ttl=60 time=6.887 ms

PING ( 56 data bytes
64 bytes from seq=0 ttl=64 time=0.093 ms

Address 1:
*** Can’t find No answer

** server can’t find NXDOMAIN

DNS kresd no reverse DNS set.

Address 1:
*** Can’t find No answer <---- no ipv6

I set no ipv6 used!

pls look to /var/kresd/hints.tmp.
All static users.