Created
August 26, 2011 13:33
-
-
Save jbuchbinder/1173404 to your computer and use it in GitHub Desktop.
DYNDNS scripts and stuff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use WWW::Mechanize; | |
my $options = "options: name (A|CNAME|ALIAS|...) value [ttl]"; | |
my $k = shift || die $options; | |
my $t = shift || die $options; | |
my $v = shift || die $options; | |
my $ttl = shift || 600; | |
my $u = "USERNAME"; | |
my $p = "PASSWORD"; | |
my $d = "DOMAIN"; | |
my $m = WWW::Mechanize->new(); | |
$m->get('https://www.dyndns.com/account/entrance/'); | |
$m->submit_form( | |
form_number => 1 | |
, fields => { | |
'username' => $u | |
, 'password' => $p | |
} | |
); | |
if ($t == 'CNAME') { | |
# CNAME record | |
$m->get("https://www.dyndns.com/account/services/zones/dns/cname.html?zone=${d}"); | |
$m->submit_form( | |
form_number => 1 | |
, fields => { | |
'host' => $k | |
, 'data' => $v | |
} | |
); | |
} elsif ($t == 'A') { | |
# A record | |
$m->get("https://www.dyndns.com/account/services/zones/dns/host.html?zone=${d}"); | |
$m->submit_form( | |
form_number => 1 | |
, fields => { | |
'host' => $k | |
, 'cur_ip' => $v | |
} | |
); | |
} else { | |
# Anything else | |
$m->get("https://www.dyndns.com/account/services/zones/dns/${d}"); | |
$m->submit_form( | |
form_number => 2 | |
, fields => { | |
'name_new' => $k | |
, 'type_new' => $t | |
, 'data_new' => $v | |
, 'ttl_new' => $ttl | |
} | |
);} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment