pavement

Set-ddns.pl router settings list

From FreeBSDwiki
Revision as of 04:21, 21 May 2006 by Jimbo (Talk | contribs)
Jump to: navigation, search

Westech WireSpeed DualConnect Home DSL Gateway

# BellSouth el cheapo residential gateway: there is no configurable username and password to set!
# Just make sure that either your WireSpeed is still set to the factory default private IP address,
# or that you adjust the router_url_string below to reflect whatever you have it set to now.
$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);
$WAN = ;
foreach $string (@body) {
    if ($WAN eq ) {
         if ($string =~ /^var IpAddress \= \"(\d{0,3}\.\d{0,3}\.\d{0,3}\.\d{0,3})\"\;/) {
               $WAN = $1;
         }
    }
}


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);


D-Link DGL-4300 802.11g MIMO "Gamer's Lounge" Router

# note: this sucker does fancy 'fake authentication' that uses some sort of session ID instead of
# standard HTTP authentication.  It's certainly possible to mimic it using LWP::Credentials, but I'm not 
# feeling the need to actually fight it through right now - and since it supports true syslog output, it might 
# be easier just to set up a syslog server and monitor incoming syslog messages for the latest incoming
# line to match /.*?IP Address (\d{0,3}\.\d{0,3}\.\d{0,3}\.\d{0,3}) and default gateway/ and work from that.
# 
# of course, since this is only a single WAN router, you could always take the cheese route and just use
# the checkip.dyndns.org method listed above. =)
Personal tools