ddns.ts is a tool to update the A / AAAA-Record of your domain registered on njal.la.
The goal is to be able to access a service in your home network when your network provider doesn’t have enough ipv4 adresses and uses DSLite.
I am aware of existing DynDNS Providers, but i wished for a open solution usable without relying on <insert some service here>.
Requirements:
The API key and the domain you wish to update are read from the environment variables, meaning you can run the program as follows:
DDNS_DOMAIN=example.com DDNS_API_KEY=example ./ddns.tsAdditionally, if you wish to change the A-record instead of the AAAA-record, you can set DDNS_IPVX=4 as environment variable (defaults to 6).
For example in a crontab:
*/1 * * * * PATH=$PATH:/root/.deno/bin DDNS_DOMAIN=example.com DDNS_API_KEY=apikey /usr/local/bin/ddns.ts >> /var/log/ddns_domain.com 2>&1Note that this doesn’t yet support creation of records and relies on there being records to edit, meaning you’ll have to create them initially.
When doing the following, keep in mind that this opens up a potential attack vector. Proceed with care.
- Open the ports to your services: By default your router should block access from outside. Make sure to create port forwarding rules for ipv6 going to your host, in this example I’ll use the name
proxy. proxywill now be reachable via its ipv6 address. To check if it works, get the ipv6 adress ofproxyusingcurl -6 api6.ipify.organd afterwards do acurl [IPV6_ADDRESS]:PORT. You should see whatever your service provides, e.g. a basic website.- create a
AAAA-record on njal.la - setup the crontab on
proxyas described in Usage
After Making your homelab reachable via ipv6, your homelab won’t be reachable in networks where ipv6 isn’t supported.
To change that, you can use a machine which is reachable via ipv4 (still necessary, sadly) to forward ipv4 requests to ipv6. It doesn’t have to have a fixed ipv4 address, as you can again use the script to modify your A-record. This machine will be called 4to6.
Make sure to achieve the following:
- your
proxyis reachable via ipv6 - your
4to6is reachable via your domain using ipv4 (check e.g. by installing apache temporarily on4to6or check using netcat)
Then, on 4to6, install socat and create the following service under /etc/systemd/system/4to6@.service (and change DOMAIN to your domain):
[Unit] Wants=network-online.target After=network-online.target [Service] ExecStart=socat -d -d TCP4-LISTEN:%i,fork TCP6:DOMAIN:%i Type=simple StandardOutput=journal StandardError=journal Restart=always [Install] WantedBy=multi-user.target
This creates a service file to which you can pass arguments. For example, to enable forwarding from ipv4 to ipv6 for port 443, do the following:
systemctl enable 4to6@443
systemctl start 4to6@443