Created
August 25, 2014 20:45
-
-
Save kralo/534339d23b077f98056e to your computer and use it in GitHub Desktop.
php script to update multiple dyndns endpoints with one url
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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