Is there a way to control dns ttl value of dynamic updates?
-
I have followed the guides here on how to set up my dns server running on pfsense to update a zone on my dns server with the host <-> ip mappings and it is working great. The only minor problem is that the dns entries created by dhcpd use a TTL of 3600 seconds. Is there a way to set this to another value. I personally want to set it to 120. Does anyone know if it is possible to change this value and if so how?
-Ivar
-
I have found a way to set the ttl used by dhcpd when updating the dns server. It is a big hack and really should be added to pfsense.
I edited /etc/services.inc to change
if ($dhcpifconf['ddnsdomain'] <> "") {
$newzone['domain-name'] = $dhcpifconf['ddnsdomain'];
$dnscfg .= " ddns-domainname "{$dhcpifconf['ddnsdomain']}";\n";
} else {
$newzone['domain-name'] = $config['system']['domain'];
}to
if ($dhcpifconf['ddnsdomain'] <> "") {
$newzone['domain-name'] = $dhcpifconf['ddnsdomain'];
$dnscfg .= " ddns-domainname "{$dhcpifconf['ddnsdomain']}";\n";
$dnscfg .= " ddns-ttl 120;\n";
} else {
$newzone['domain-name'] = $config['system']['domain'];
}$dnscfg .= " ddns-ttl 120;\n"; is what is added.
-
What is the lease time your getting from the dhcp server on your interface? Setting a ttl of 120 seconds is going to generate a bit more dns traffic than a 3600 ttl.. Why would you need it so short.. Does your IP actually change that often?
Normally dhcp is renewed and will stay the same IP for years!!! Unless it goes offline for extended period and that lease expires and someone else gets it.
-
The domain i do the dynamic updates to is hosted by bind on pfsense itself. This means that there is not much extra internet traffic generated by a low ttl as the clients are set to use pfsense as it's dns server.
The reason I want a low ttl is that when I get a new device I assign a static ip address as soon as it has gotten a dynamic address fromt he dhcp server so that I can be lazy and use the view dhcp leases in pfsense to assign a static address saving to enter the mac address manually with a 1hour ttl it will then take a long time until i can use the hostname to reach the device as it will point to the dynamic address it got originally.
-
????
The DNS TTL only affects devices that have queried the name. If a device hasn't requested an IP for the host name it will not have the address in it's cache. So, let the new device boot up, get it's MAC, create the static entry and point the host name to it. Then, when some other device queries that name, it will get the static address.
I think you may be imaging problems that don't exist. You'd only have to worry about DNS TTL if a host name had been in use and then the address changed. The TTL only affect pfSense for host names learned from elsewhere. When you control the host names on a local DNS, for local devices, there's no cache in pfSense to worry about, as it will rely on what's saved in /etc/hosts.