Adjusting the Time-To-Live (TTL) in DynamicDNS (os-ddclient) Configuration in OPNsense
Table of Contents
Unfortunately, in OPNsense, it is not possible to set the TTL (Time to Live) for Dynamic DNS, which means DNS entries always have a TTL of 10800 seconds or 3 hours. This limitation undermines the purpose of Dynamic DNS, in my opinion.
To address this, I present a short script that sets the TTL to 300 seconds at system startup. The script adds the line ttl=300 \
after each line that begins with password=
. We create the script using Syshook with the “Early” start option, as described in the OPNsense Documentation Autorun.
Script #
We create the script using Syshook with the “Early” start option as described in the OpnSense Documentation Autorun.
The subdirectory after rc.syshook.d
indicates when the script will be executed.
- early: means that a script is started before the system network start.
Instructions #
- DDClient Backup:
cp /usr/local/etc/ddclient.conf /usr/local/etc/ddclient.conf.bak
- Create Script File:
vi /usr/local/etc/rc.syshook.d/early/50-add_ttl.sh
- Insert Script Content:
#!/bin/sh
# Define the file path
DDCLIENT_CONF="/usr/local/etc/ddclient.conf"
# Use sed to insert 'ttl=300 \' followed by a newline after any line starting with 'password='
sed -i '' '/^password=/a\
ttl=300 \\\
' "$DDCLIENT_CONF"
- Make Script Executable:
chmod +x /usr/local/etc/rc.syshook.d/early/50-add_ttl.sh
- Test Script:
Manually execute the script to ensure it works:
/usr/local/etc/rc.syshook.d/early/50-add_ttl.sh
- Verify DDClient Config:
Check if the line ttl=300 \
has been correctly added.
vi /usr/local/etc/ddclient.conf
This is a very basic script, and I would love to hear your suggestions for improvements in the comments! 😊