3update-0.6.pl(旧miniDNS)実験記

| コメント(0)

2006/09/06 追記
現在3update-0.8.pl に更新されています。ルータのアドレスを読む必要がなくなりました。設定ファイルの変更で対応可能となっていますので、最新版をお薦めします。

miniDNS のサービスも進化しているようです。先日、サービス変更のお知らせが届きました。今までは、IPアドレスの更新は手動で行っていましたが、このお知らせにあった 3update-0.6.pl プログラムを実験しましたので公開します。

【概要】

CATV 回線にヤマハ製ルーター RT56v を介して、家庭 LAN を構築しています。LAN 上に Linux サーバーを Private IP Address で構成しています。CATV 回線のグローバル IP アドレスが変更になる都度、3update サイトへ更新処理させるための仕組みです。

プログラムのダウンロード

プログラムのソース:3update-0.6.tar.gz ( ダウンロード先 )

これを解凍すると二つのプログラムがでてきますので、指定箇所にコピーします。

・3update-0.6.pl ( copy 先: /usr/local/bin/3update-0.6.pl )
・3update.conf ( copy先: /etc/3update.conf )

構成ファイルの修正

3update.conf の修正 (赤字の部分を修正します)

#
# this is a sample configuration file for 3update v0.6
#
interface = ppp0
login_id = xxxxxx <---- 旧miniDNS のログイン・アカウント名
password = pppppp <-- ログインパスワード
hostname = zzzzz.net <-- 登録している独自ドメイン名

#
# If your public IP is eaten by the router(e.g. your machine only get 192.168.x.x),
# please set $no_public_ip to true and $report_url to the URL of an IP address
# reporting site. However, you should get consent of the reporting site before
# using it.
(注:この英語はおじさんには理解できませんでしたが、大体「LAN内でPrivateIPアドレスをサーバーにアサインしている場合には、no_public_ip を true へ変更し、ルーターのWAN側 Global IP Addressを取得するプログラムが必要です」と行っている見たいです。)

#
no_public_ip = true <--- Private IP アドレスをサーバーにアサインしている場合
report_url = http://192.168.x.xxx/cgi-bin/rt56v.cgi <--- サーバー・アドレスと、ヤマハ製ルーター RT56v の global IP Address を取得する自作プログラムを指定する


#
# Advacned options. You normally don't have to touch these if you are on Linux.
#
log_file = /var/log/3update.log
lock_file = /var/run/3update.pid
ifconfig = /sbin/ifconfig

グローバルアドレスの取得プログラム

以下が自作のプログラムです。単体でもグローバル・アドレスを取得して表示してくれます。
赤字の部分をご自分の環境に合わせて修正し、cgi プログラムの動くところへアップロードしてテストください。

前提条件: Perl Module の Net:Telnet を CPAN からインストールしておくこと (2005/09/05更新)

#! /usr/bin/perl

################################################
# prog id : rt56v.cgi
# Get IP Address for RT56v Release 0.1
#
# Copyright 2004 zbs reserved.
#
# This program is free software; you can redistribute
# it and/or modify it under the GPL.
#
# Last Updated: 02-Dec-2004
#
################################################

#GetNewIP for RT-56v

use Net::Telnet ();
my($lines,$t,$pass,$rthost);
$rthost = '192.168.0.1'; <--- RT56v ルーターの IP アドレス
$pass = 'abcdefg'; <--------ログイン・パスワード

$t = new Net::Telnet (-host => "$rthost");
## Wait for first prompt
$t->waitfor('/Password:.*$/');
$t->print("$pass");
$t->waitfor('/>.*$/');
$t->print("show ip lan2");

($lines) = $t->waitfor('/>.*$/');
$new_ip = "0.0.0.0";

foreach($lines){
if(/IPアドレス:/){
$position = index($',"/");
$new_ip = substr($',1,$position - 1);
}
}

#return($new_ip);

print "Content-type:text/html\n\n";
print $new_ip;

結果

/var/log/3update-0.6.log に以下が出ましたので、稼働しているとは判断しています。

[2004-12-02 21:07:06] *** 3update 0.6 Started ***
[2004-12-02 21:07:07] ikezoe.net mapped to 220.208.242.85

みなさんのお役に立ちましたら嬉しい限りです。

補足1

小生の場合は、関連するほとんどの perl module が足りないため追加しました。
webmin の Others - Perl Modules は、モジュールの追加が容易に行え便利でした。

補足2

apache.conf に Dummy Virtual Server の指定をしたら rt56v.cgi へアクセスできなくなりました。原因は ip アドレスでアクセスした場合、Dummy サーバーへアクセスして cgi-bin ディレクトリーが Linux の Default cgi-bin を見に行っていました。(2005/3/11)

対応 apache.conf の dummy server section に /cgi-bin をcgi プログラムがある /home/cgi-bin へ alias リンクをさせました。 ScriptAlias /cgi-bin/ /home/cgi-bin/

補足3

サーバーをDebian Sarge へ新規更新したとき、premature end of stript header エラーメッセージがでてびっくり!
原因は、Perl Module の Net::Telnet が入っていませんでした。(2005/09/05)

コメントする

最近のブログ記事

Windows XPのOutlook Express 6.0 のスペルチェック
近所の会社の社長さんは Windows …
白菜の花
畑は春の陽気ですね。2/23以降朝の冷え…
css - リストの黒丸や四角の黒などが表示できない
比較的簡単なページを作成しています。リス…

おすすめ