AirStationの設定をValueDomainに定期的につっこむ
AirStation WHR-HP-GNという前提での、ValueDomain定期更新スクリプト。各AirStationの型番毎にqueryが判明すれば汎用化できるんだろうけど、そこまでやる意味があるか分からないので。
AirStationにもAPI備わってればいいのになぁとはよくおもう。
#!/usr/local/bin/perl use strict; use warnings; use Regexp::Common qw/net/; use Encode qw(decode encode); use WWW::Mechanize; use URI; use Net::DNS::ValueDomain::DDNS; my $user = <id>; my $pass = <pass>; my $url = "http://192.168.11.1/cgi-bin/cgi?"; my $ip = ''; my $airstation = URI->new($url); my $mech = WWW::Mechanize->new( autocheck => 1 ); $mech->credentials($user,$pass); $airstation->query_form( req => 'twz' ); $mech->get( $airstation->as_string ); $airstation->query_form( req => 'tfr', id => '41' ); $mech->get( $airstation->as_string ); $airstation->query_form( req => 'frm', frm => 'info.html' ); $mech->get( $airstation->as_string ); my $content = $mech->content; my @content = split(/\n/, $content); foreach my $line ( @content ) { $line =~ s/\s//g; if ( $ip eq '' && $line =~ /$RE{net}{IPv4}/o ) { $ip = encode('utf-8', $line); } } $ip =~ s/<td>//; $airstation->query_form( req => 'twz', frm => 'logout.html' ); $mech->get( $airstation->as_string ); my $ddns = Net::DNS::ValueDomain::DDNS->new; $ddns->update( domain => 'haoyayoi.net', password => $ddns_pass, host => '*', ip => $ip, );