| Author |
Message |
robertrath Junior Member
Joined: 18 May 2005 Posts: 6
|
Posted: 04-10-2006 09:05 PM Post subject: DNS Client For Linux |
|
|
Has anyone tried to setup a solution to update the DNS from a linux client?
I have viewed the whitepaper regarding this topic and get the idea of how it could be done but I'd rather not re-invent the wheel.
...Robert |
|
| Back to top |
|
 |
tclark Junior Member
Joined: 30 Jun 2006 Posts: 1
|
Posted: 06-30-2006 07:52 AM Post subject: DNS Client For Linux |
|
|
You can do this with a quick shell script:
[code:1]
#!/bin/sh
wget -q --http-user=YOUR_USERNAME \
--http-passwd=YOUR_PASS \
'https://www.changeip.com/update.asp?u=YOUR_USERNAME&cmd=update&set=1&offline=0'
[/code:1]
Put this in cron to run every hour or so. |
|
| Back to top |
|
 |
danm Junior Member
Joined: 20 Oct 2005 Posts: 15
|
Posted: 08-12-2006 12:51 PM Post subject: |
|
|
Though it's not as easy, you should try to only send updates if something has changed. If you get http://ip.changeip.com and compare it to the previous version and only update when it changes you won't be sending as many updates. I know some DDNS servers will block you if you send invalid updates too often.
-Dan |
|
| Back to top |
|
 |
robertrath Junior Member
Joined: 18 May 2005 Posts: 6
|
Posted: 02-04-2007 04:52 AM Post subject: My Solution To DNS Update, Rock Solid and Very Happy! |
|
|
Here is my solution by modifications to Tristan Nixon's original script.
This script compares the dns record with the router IP (in my case Netcomm NB9W) and if they differ enforces the update.
I also have a different version for Netcomm NB5W which requires a POST mechanism for router/modem login instead.
... Robert
#!/usr/bin/perl -Tw
# updatedns - ChangeIP.com Auto Client Script
# by Tristan Nixon ( corvi42@silencegreys.com )
# based very loosely upon the script by: Bob Lee (crazyboblee@hotmail.com)
# License: http://www.gnu.org/copyleft/gpl.html
#
# I have tried to make this program responsible in
# such a way that it will be optimal for both running as a cron
# task to update the dns should your ip change, and as part of a
# network init script
# it will also update your /etc/hosts file so that your hostname
# is set correctly for local resolution
# ( ie it adds an entry with the ppp ip when you go online, and modifies this to a local address when offline )
# sometimes apache or other daemons
# complain if you're locally using a hostname that doesn't properly resolve,
# this should solve this problem
#
# usage: updatedns <offline>
#
# if the command is run without arguments, it will
# check if it is neccessary to update the dns
# ( ie if the ppp interface has a different ip from the dns record )
# and then do so this is how it should be run if you want to set
# or update a dns record when your machine goes online or when your ip changes
#
# if it is run with an argument: 'updatedns offline'
# ( or any argument that resolves to true in perl: 'updatedns 1' or 'updatedns foobar' etc. )
# then it will set the dns record to point to $public_offlineip
#
# all of this is logged to /var/log/updatedns.log
#
# you must edit the variables below to get this thing working for you
# important variables:
# $uid - your changeip.com userid
# $pwd - your changeip.com password
# $hostname - the hostname to which you want your computer to be bound
# $offlineip - the ip for your hostname so you can get to your own machine when you're offline
# $public_offlineip - the ip others should go to when you're offline
# $iface - your dynamic / dialup interface, this should be fine as it is for most people
# $hostsfile - location of your local hosts file, this should be fine for most people
# $logfile - the location of the logfile, this should be fine for most people
# $dnsserver - the server & port to go to to update - I don't see why you'd want to change this
## ##
## START MAIN PROGRAM ##
## ##
# make the environment safe
clean_env();
$ENV{PATH} = '/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin';
# variables
my $offline = $ARGV[0] ? 1 : 0;
my $uid = 'myuid'; # set this to your changeip.com userid
my $pwd = 'mypwd'; # set this to your changeip.com password
my $hostname = 'myhostname'; # set this to your hostname
my $offlineip = '127.0.0.1'; # set this to your own local interface
my $public_offlineip = $offlineip; # set this to the ip other should go to when you're offline
my $iface = 'ppp0';
my $hostsfile = '/etc/hosts';
my $logfile = '/var/log/updatedns.log';
my $dnsserver = 'www.changeip.com:443';
my $pppip = get_router_ip();
my $dns_entry = get_dns();
print "ip: $pppip\n";
print "dns: $dns_entry\n";
my $ruid = 'myrouteradmin:myrouterpwd';
my $rurl = 'http://192.168.1.1/wancfg.cmd?action=view';
print "checking match\n";
# if we already match the dns record, exit now
#( ! $offline && $pppip eq $dns_entry ) and exit( 0 );
( $pppip eq $dns_entry ) and exit( 0 );
print "updating records\n";
# update the dns
update_dnsset1();
## ##
## END MAIN PROGRAM ##
## ##
# subroutines
sub clean_env
{
foreach my $key ( %ENV ){
$ENV{$key} = untaint( $ENV{$key} );
}
}
sub untaint{
my $stringToClean = $_[0];
( ! defined( $stringToClean ) || $stringToClean |
|
| Back to top |
|
 |
robertrath Junior Member
Joined: 18 May 2005 Posts: 6
|
Posted: 03-15-2007 09:45 AM Post subject: Linux Client Status Update |
|
|
I have been using my update linux clients for both NB9 and NB5W routers now for quite some time and the mechanism is absolutely bullet proof. This is more than I can say for Homing Beacon.
...Robert  |
|
| Back to top |
|
 |
|