Skip to content

Instantly share code, notes, and snippets.

@kralo
Created August 25, 2014 20:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kralo/534339d23b077f98056e to your computer and use it in GitHub Desktop.
Save kralo/534339d23b077f98056e to your computer and use it in GitHub Desktop.
php script to update multiple dyndns endpoints with one url
<?php
/**
* Quick and dirty script to update ipv4 and ipv6 records simultaneously by the fritz box ddns function.
* afraid.org offered only one-record-per-url so this takes the fritzbox input and makes two separate calls to afraid.org
* Fritzbox settings should be:
* url = point to this script. attach parameters auth_key, ipv4 and ipv6. Lookup the fritzbox help to find the parameter placeholder, should look like
* http://path-to-this-script.com/script.php?auth_key=<username>&ipv4=<ipaddr>&ipv6=<ip6addr>
* domain: your domain
* username: yourawesomekey below
* password anything you want, doesn't matter
*/
$auth_key = 'yourawesomekey_privately_defined'; //prevent anyone who knows the simple script url to update your ip adresses
if ($_GET['auth_key'] == $auth_key) {
$ipv4 = $_GET['ipv4'];
$ipv6 = $_GET['ipv6'];
function curl_fetch($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
$data = curl_exec($ch);
$error = curl_error($ch);
curl_close($ch);
if (!empty($error)) {
echo $error;
}
return $data;
}
//Make sure to enter the correct update URL (mind the correct token!)
$ipv4_url = 'http://freedns.afraid.org/dynamic/update.php?<token4>&address=' . $ipv4;
echo curl_fetch($ipv4_url);
//Make sure to enter the correct update URL (mind the correct token!)
$ipv6_url = 'http://freedns.afraid.org/dynamic/update.php?<token6>&address=' . $ipv6;
echo curl_fetch($ipv6_url);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment