#!/usr/bin/perl # Dynamic DNS (justlinux.com) update with LinkSys DSL/Router # Hermelito Go # 12/10/2000 # # perl -MCPAN -e 'install Bundle::LWP' # use LWP::UserAgent; use HTTP::Cookies; $linksyspassword = 'Enter your Linksys DSL/Router Password'; $password = 'Enter your justlinux.com password'; $user = 'Enter your justlinux.com username'; $dnsid = "Hidden variable, you can view it using your browser's source viewer"; $ua = new LWP::UserAgent; $req = new HTTP::Request GET => 'http://192.168.1.1/Status.htm'; $req->authorization_basic('',$linksyspassword); $res = $ua->request($req); if ( $res->is_success ) { @data = split //, $res->as_string; } else { print "Error: unable to get router's address\n"; exit 1; } foreach $data (@data) { if ( $data =~ /IP Address:/ ) { $data =~ s/<\/td><\/tr>//g; # trim extraneous tags $data =~ s/<(.)*>//; # $ip = $data; # The second IP is what we want. } } $ua = new LWP::UserAgent; $cookies = new HTTP::Cookies; $ua->cookie_jar($cookies); $req = new HTTP::Request POST => "http://www.justlinux.com/bin/dologin"; $req->content_type('application/x-www-form-urlencoded'); $req->content("username=$user&password=$password"); # Login first to get the cookies initialized $ua->request($req); $req = new HTTP::Request POST => "http://www.justlinux.com/bin/controlpanel/dyndns/update.pl"; $req->content_type('application/x-www-form-urlencoded'); $req->content("dnsid=$dnsid&ip=$ip&action=update"); $req->authorization_basic($user,$password); $res = $ua->request($req); if ( ! $res->is_success || $res->as_string !~ /Hostname\'s ip address updated/ ) { print "Error: Unable to connect to Justlinux\n"; exit 1; } else { print "DSL Gateway $ip was registered successfully\n"; }