Using cURL for Dynamic DNS Updates¶
cURL is a versatile command-line tool that can be used to update DNS records in Poweradmin. Here are various examples of using cURL with the Dynamic DNS update system.
When you are setting things up for the first time, append
&verbose=1to any URL below. The server then returns a human-readable status message ("Your hostname has been updated.", "Invalid username or password...") instead of a two-letter code, which makes misconfiguration much easier to spot. Drop the parameter once your client is working.
Basic Update Examples¶
Update IPv4 Address¶
curl -u username:password "https://dns.example.com/dynamic_update.php?hostname=host.example.com&myip=192.0.2.1"
Automatic IP Detection¶
curl -u username:password "https://dns.example.com/dynamic_update.php?hostname=host.example.com&myip=whatismyip"
Update IPv6 Address¶
curl -u username:password "https://dns.example.com/dynamic_update.php?hostname=host.example.com&myip6=2001:db8::1"
Advanced Usage¶
Combined Multiple IPv4 and IPv6 Update¶
# Update multiple A records and single AAAA record in one request
curl -u user:pass "https://yourhost/dynamic_update.php?hostname=host.example.com&myip=1.2.3.4,5.6.7.8&myip6=2001:db8::1&dualstack_update=1"
Dual-Stack Update¶
curl -u username:password "https://dns.example.com/dynamic_update.php?hostname=host.example.com&myip=192.0.2.1&myip6=2001:db8::1&dualstack_update=1"
Multiple IP Addresses¶
curl -u username:password "https://dns.example.com/dynamic_update.php?hostname=host.example.com&myip=192.0.2.1,192.0.2.2"
Using URL Parameters Instead of Basic Auth¶
curl "https://dns.example.com/dynamic_update.php?username=user&password=pass&hostname=host.example.com&myip=192.0.2.1"
Scripting Examples¶
Basic Update Script¶
#!/bin/bash
USERNAME="your_username"
PASSWORD="your_password"
HOSTNAME="your.hostname.com"
SERVER="https://dns.example.com/dynamic_update.php"
curl -s -u "$USERNAME:$PASSWORD" "$SERVER?hostname=$HOSTNAME&myip=whatismyip"
Periodic Update Script¶
#!/bin/bash
USERNAME="your_username"
PASSWORD="your_password"
HOSTNAME="your.hostname.com"
SERVER="https://dns.example.com/dynamic_update.php"
INTERVAL=300 # Update every 5 minutes
while true; do
curl -s -u "$USERNAME:$PASSWORD" "$SERVER?hostname=$HOSTNAME&myip=whatismyip"
sleep $INTERVAL
done
Error Handling¶
The endpoint always answers with HTTP 200, even on errors. The result is the status line in the body (good, nochg, badauth, nohost, ...), so test that instead of the HTTP code:
response=$(curl -s -u "$USERNAME:$PASSWORD" "$SERVER?hostname=$HOSTNAME&myip=whatismyip")
case "$response" in
good*|nochg*) echo "Update successful" ;;
*) echo "Update failed: $response" ;;
esac
Security Considerations¶
- Always use HTTPS to protect credentials
- Consider using Basic Authentication instead of URL parameters
- Store credentials securely, not in plain text
- Use specific IP ranges if possible
- Monitor for unusual update patterns