Loopia har annars DynDNS-stöd som du lätt kan skripta något emot. Så här ser mitt (halvhackiga) skript ut:
PHP-kod:
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://dns.loopia.se/checkip/checkip.php');
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
$ip_site = curl_exec($ch);
preg_match("/^.*: ([^<]*).*$/", $ip_site, $matches);
$current_ip = $matches[1];
@$old_ip = file_get_contents('last_ip');
if($current_ip == $old_ip) {
die(date('Y-m-d H:i:s') . ': IP not updated'."\n");
}
function updateip($host, $ip) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://dns.loopia.se/XDynDNSServer/XDynD\
NS.php?hostname={$host}&myip={$ip}&wildcard=NOCHG");
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, FALSE);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_USERPWD, "blaha:password"); //user:pass here
// curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
echo "{$host}: ".curl_exec($ch) ."\n";
}
echo "New ip: $current_ip\n";
$sites = array('sajt.com', 'sajt2.com', 'sajt3.se');
foreach($sites as $site) {
updateip($site, $current_ip);
updateip("www.$site", $current_ip);
}
echo "\n";
file_put_contents('last_ip', $current_ip);
?>
Jag kör det i crontab var tionde minut. Ge dina domäner hos Loopia en låg TTL (5-10 minuter) så cachas de inte så lång tid och uppdateringarna slår igenom fort.