🌐 Use Gandi, Porkbun and Cloudflare for DynDNS with FritzBox routers
MIT License
Web service to allow FritzBox routers to update Gandi, Cloudflare and Porkbun DNS entries when obtaining a new IP address. Also available as a HomeAssistant addon.
config.sample.toml
to config.toml
enabled
to true
zoneId
as per this article
Zone.DNS
permissions and set it to the zone your domain is inInternet
-> Permit Access
-> DynDNS
User-defined
as Providerhttp://{HOST}:{PORT}/api/update?domain={DOMAIN}&subdomain={SUBDOMAIN}&ip=<ipaddr>®istrar=<username>
{HOST}
and {PORT}
with your deployment of the application
9595
{DOMAIN}
with your base domain
yourdomain.com
{SUBDOMAIN}
with your subdomain or comma separated subdomains
subdomain
or sudomain1,subdomain2
Domain Name
field
subdomain.domain.com
(if you use multiple subdomains, just choose any of those)Username
field, either gandi
, cloudflare
or porkbun
Password
field
Your settings should look something like this:
Right after you save the settings, your FritzBox will make a request to the application. You should see the following success message in its log:
Your FritzBox will now automatically communicate new IPs to the application.
If you deploy this application outside your local network, I'd recommend you to use HTTPS for the requests. Check below for an example on how to reverse proxy to this application with NGINX.
To create a systemd service and run the application on boot, create a service file, for example under
/etc/systemd/system/frigabun.service
.
Service file contents:
[Unit]
Description=FritzGandi LiveDNS Microservice
[Service]
WorkingDirectory=/path/to/frigabun
ExecStart=/path/to/frigabun/executable
User=youruser
Type=simple
Restart=on-failure
RestartSec=10
[Install]
WantedBy=multi-user.target
Don't run this as root. Make sure your User
has access rights to the WorkingDirectory
where the executable is in.
Reload daemon, start the service, check its status:
sudo systemctl daemon-reload
sudo systemctl start frigabun.service
sudo systemctl status frigabun
If all is well, enable the service to be started on boot:
sudo systemctl enable frigabun
If you want to host the service and make sure it uses HTTPS, you can use a reverse proxy. Shown below is an example of an NGINX + LetsEncrypt reverse proxy config for this microservice.
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name frigabun.yourdomain.com;
# SSL
ssl_certificate /etc/letsencrypt/live/frigabun.yourdomain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/frigabun.yourdomain.com/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/frigabun.yourdomain.com/chain.pem;
# security headers
add_header X-Frame-Options "DENY";
add_header X-XSS-Protection "1; mode=block" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Referrer-Policy "no-referrer-when-downgrade" always;
add_header Content-Security-Policy "default-src 'self' http: https: data: blob: 'unsafe-inline'" always;
add_header Strict-Transport-Security 'max-age=31536000; includeSubDomains; preload';
add_header X-Permitted-Cross-Domain-Policies master-only;
# . files
location ~ /\.(?!well-known) {
deny all;
}
# logging
access_log /var/log/nginx/frigabun.yourdomain.com.access.log;
error_log /var/log/nginx/frigabun.yourdomain.com.error.log warn;
# reverse proxy
location / {
proxy_pass http://127.0.0.1:9595;
proxy_http_version 1.1;
proxy_cache_bypass $http_upgrade;
# Proxy headers
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Port $server_port;
# Proxy timeouts
proxy_connect_timeout 60s;
proxy_send_timeout 60s;
proxy_read_timeout 60s;
}
}
# HTTP redirect
server {
listen 80;
listen [::]:80;
server_name frigabun.yourdomain.com;
# ACME-challenge
location ^~ /.well-known/acme-challenge/ {
root /var/www/_letsencrypt;
}
location / {
return 301 https://frigabun.yourdomain.com$request_uri;
}
}