Custom domains and ttl

Hello,
I searched for how to change the TTL for a domain and found the post about changing local-ttl in 01-pihole.conf. However, that file is regenerated every time phole is restarted. I tried creating a 99-pihole.conf file where I added "local-ttl=60" and pihole refused to start and kept restarting.

Anyway, I don't actually want to change the ttl for all domains but happy to do so if that is the only option within Pihole. I need to change the TTL for my local .lan domains so that clients don't have to query Pihole every time.

Any help would be greatly appreciated.

p.s. I read somewhere in the forum about using host-record=unifihostname,IP,TTL but that also broke Pihole

Are you running Pi-hole in Docker? If not, the file is regenerated on repair or update only, not on a Pi-hole restart.

How did it break Pi-hole?

This is because you had a conflicting entry in different configuration files.

Thanks @jfb
Thank you very much for your prompt reply.

I am indeed running it in Docker.

The container would start and I could see "::: Starting docker specific checks & setup for docker pihole/pihole" in the log before seemingly crashing and restarting the container.

Adding the host-record=hostname,ip,ttl causes it to continuously restart the container and I could see the following in the log
dnsmasq: Bad name in host-record at line 14 of /etc/dnsmasq.d/99-pihole.conf

The entry is "host-record=.debianvm.lan,192.168.10.11,3600"

I added the dot before debianvm.lan to make it a wildcard entry.

I previously had "address=/.debianvm.lan/192.168.10.11" and that used to work fine.

That configuration line uses dnsmasq syntax.

host-record=<name>[,<name>....],[<IPv4-address>],[<IPv6-address>][,<TTL>]

Add A, AAAA and PTR records to the DNS. This adds one or more names to the DNS with associated IPv4 (A) and IPv6 (AAAA) records. A name may appear in more than one --host-record and therefore be assigned more than one address. Only the first address creates a PTR record linking the address to the name. This is the same rule as is used reading hosts-files. --host-record options are considered to be read before host-files, so a name appearing there inhibits PTR-record creation if it appears in hosts-file also. Unlike hosts-files, names are not expanded, even when --expand-hosts is in effect. Short and long names may appear in the same --host-record, eg. --host-record=laptop,laptop.thekelleys.org,192.168.0.1,1234::100

If the time-to-live is given, it overrides the default, which is zero or the value of --local-ttl . The value is a positive integer and gives the time-to-live in seconds.

Host-records can't be wildcards.

Oh I see.

Just tried it with host-record=debianvm.lan,192.168.10.11,3600 and it's working but only for that hostname.

Is there a workaround similar to address=/.debianvm.lan/192.168.10.11 where one can add TTL

I tried cname=*.debianvm.lan,debianvm.lan,3600 and got NXDOMAIN :frowning:

I don't think there is a similar option, but Man page of DNSMASQ would be a good place to read through.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.