pavement

Set-ddns.pl router settings list

From FreeBSDwiki
(Difference between revisions)
Jump to: navigation, search
(Westech WireSpeed DualConnect Home DSL Gateway)
(Xincom Twin Wan Router XC-DPG502)
Line 1: Line 1:
 
== Xincom Twin Wan Router XC-DPG502 ==
 
== Xincom Twin Wan Router XC-DPG502 ==
  
 +
# This is a dual-homed router.  This code block assumes cable on WAN1 and dsl on WAN2, with a preference
 +
# for WAN1.  So three host records are kept: dynamic.domain.net for the default, cable.dynamic.domain.net
 +
# for WAN1, and dsl.dynamic.domain.net for WAN2.  If you get fancy, you could even set something tricky
 +
# up on the server side to check WAN1 and WAN2 from the other side after they're established, and automatically
 +
# fail the "default" host, dynamic.domain.net, over to whichever side is still up if one of them fails.
 +
 
  $ROUTER_URL = '192.168.0.1/netstat.htm';
 
  $ROUTER_URL = '192.168.0.1/netstat.htm';
 +
$ROUTER_USERNAME = 'admin';
 +
$ROUTER_PASSWORD = 'password';
 
   
 
   
 +
$HOST0 = 'dynamic.domain.net';
 +
$HOST1 = 'cable.dynamic.domain.net';
 +
$HOST2 = 'dsl.dynamic.domain.net';
 +
 +
$router_url_string = 'http://' . $ROUTER_USERNAME . ':' . $ROUTER_PASSWORD . '@' . $ROUTER_URL;
 +
$ua = LWP::UserAgent->new;
 +
$req = HTTP::Request->new('GET',$router_url_string);
 +
$resp = $ua->request($req)->as_string();
 +
 +
# Simplest to just count the dotted quads: WAN1 and WAN2 are the second and third one in.
 
  $_ = $resp;
 
  $_ = $resp;
 
  ($ip1, $ip2, $ip3) = /\d{0,3}\.\d{0,3}\.\d{0,3}\.\d{0,3}/gs;
 
  ($ip1, $ip2, $ip3) = /\d{0,3}\.\d{0,3}\.\d{0,3}\.\d{0,3}/gs;
Line 8: Line 26:
 
  $WAN1 = $ip2;
 
  $WAN1 = $ip2;
 
  $WAN2 = $ip3;
 
  $WAN2 = $ip3;
 +
 +
# You don't want to cycle through set-ddns.pl for each host - it's MUCH slicker and quicker to send all
 +
# three updates in a single nsupdate invocation.  Note: I chose to skip the "show" command on nsupdate here.
 +
# It's handy for manual troubleshooting, but unnecessary once you have everything working and you're relying
 +
# on a crontab piping the output to /dev/null anyway.
 +
 +
chdir ($KEYDIR);
 +
open (NSUPDATE, "| /usr/sbin/nsupdate -k $KEYFILE");
 +
print NSUPDATE "server $NAMESERVER\n";
 +
print NSUPDATE "update delete $HOST0 A\n";
 +
print NSUPDATE "update delete $HOST1 A\n";
 +
print NSUPDATE "update delete $HOST2 A\n";
 +
print NSUPDATE "update add $HOST0 $TTL A $WAN1\n";
 +
print NSUPDATE "update add $HOST1 $TTL A $WAN1\n";
 +
print NSUPDATE "update add $HOST2 $TTL A $WAN2\n";
 +
print NSUPDATE "send\n";
 +
close (NSUPDATE);
  
 
== Westech WireSpeed DualConnect Home DSL Gateway  ==
 
== Westech WireSpeed DualConnect Home DSL Gateway  ==

Revision as of 03:04, 21 May 2006

Xincom Twin Wan Router XC-DPG502

# This is a dual-homed router.  This code block assumes cable on WAN1 and dsl on WAN2, with a preference 
# for WAN1.  So three host records are kept: dynamic.domain.net for the default, cable.dynamic.domain.net
# for WAN1, and dsl.dynamic.domain.net for WAN2.  If you get fancy, you could even set something tricky 
# up on the server side to check WAN1 and WAN2 from the other side after they're established, and automatically 
# fail the "default" host, dynamic.domain.net, over to whichever side is still up if one of them fails.

$ROUTER_URL = '192.168.0.1/netstat.htm';
$ROUTER_USERNAME = 'admin';
$ROUTER_PASSWORD = 'password';

$HOST0 = 'dynamic.domain.net';
$HOST1 = 'cable.dynamic.domain.net';
$HOST2 = 'dsl.dynamic.domain.net';

$router_url_string = 'http://' . $ROUTER_USERNAME . ':' . $ROUTER_PASSWORD . '@' . $ROUTER_URL;
$ua = LWP::UserAgent->new;
$req = HTTP::Request->new('GET',$router_url_string);
$resp = $ua->request($req)->as_string();

# Simplest to just count the dotted quads: WAN1 and WAN2 are the second and third one in.
$_ = $resp;
($ip1, $ip2, $ip3) = /\d{0,3}\.\d{0,3}\.\d{0,3}\.\d{0,3}/gs;

$WAN1 = $ip2;
$WAN2 = $ip3;

# You don't want to cycle through set-ddns.pl for each host - it's MUCH slicker and quicker to send all
# three updates in a single nsupdate invocation.  Note: I chose to skip the "show" command on nsupdate here.
# It's handy for manual troubleshooting, but unnecessary once you have everything working and you're relying
# on a crontab piping the output to /dev/null anyway.

chdir ($KEYDIR);
open (NSUPDATE, "| /usr/sbin/nsupdate -k $KEYFILE");
print NSUPDATE "server $NAMESERVER\n";
print NSUPDATE "update delete $HOST0 A\n";
print NSUPDATE "update delete $HOST1 A\n";
print NSUPDATE "update delete $HOST2 A\n";
print NSUPDATE "update add $HOST0 $TTL A $WAN1\n";
print NSUPDATE "update add $HOST1 $TTL A $WAN1\n";
print NSUPDATE "update add $HOST2 $TTL A $WAN2\n";
print NSUPDATE "send\n";
close (NSUPDATE);

Westech WireSpeed DualConnect Home DSL Gateway

# BellSouth el cheapo residential gateway: there is no configurable username and password to set!

$router_url_string = 'http://192.168.1.254/homeBS.htm';

$ua = LWP::UserAgent->new;
$req = HTTP::Request->new('GET',$router_url_string);
$resp = $ua->request($req)->as_string();

@body = split (/\n/, $resp);
$IP1 = ;
foreach $string (@body) {
    if ($IP eq ) {
         if ($string =~ /^var IpAddress \= \"(\d{0,3}\.\d{0,3}\.\d{0,3}\.\d{0,3})\"\;/) {
               print "Found: $string \n";
               $IP1 = $1;
         }
    }
}

$WAN1 = $ip1;
Personal tools