ValuedomainのDNSサーバからの伝播が遅いので、MyDNSにもユーザー登録してみた。ValuedomainのDNSサーバ設定画面で、Valuedomainの5つのサーバもそのまま残してMyDNSの3つのDNSを追加。
ddclientがエラーを吐く。どうやらMyDNSに対応していないような。パッチも公開されているが、すでにValuedomain用パッチを当てている上にさらに当てるのはどうも気が進まないので、スクリプト書いてみた。
<?php $ipfile=dirname(__FILE__)."/ip.txt"; $ip_url=rtrim(file_get_contents("http://unchara.com/cgi-bin/ip.cgi")); #グローバルIPアドレスを表示するcgi $ip_last = rtrim(file_get_contents($ipfile)); #初回はウォーニングが出る $update_last = filemtime($ipfile); #同上 $days = 7; #IPアドレス変更がなくても更新する if(preg_match("/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/",$ip_url,$ip_current) == 1){ #完璧ではないけど if($ip_last != $ip_current[0]){ $message = "IP Address changed from $ip_last to $ip_current[1] .\n"; update_dns(); }elseif(time() > $update_last + 3600*24*$days){ $message = "$days days has passed since last update.\n"; update_dns(); }else { echo "No need to update.\n"; } } function update_dns(){ #サブルーチン global $ipfile,$ip_current,$message; $ret = file_get_contents("http://www.mydns.jp/directip.html?MID=id&PWD=pass&IPV4ADDR=$ip_current[1]"); $message .="\n\n" . strip_tags($ret); $headers="From: nanchara@kazz.mine.nu\n"; mb_send_mail("kaanchara@kazz.mine.nu","MyDNS update",$message,$headers); file_put_contents($ipfile,$ip_current[1]); } ?>
これをcronに登録して10分おきに実行。