As anyone know (and should know) EditDNS it’s the best alternative for DNS Management and the best of all it is FREE 😉
Here I wrote/adapted some code which will allow you to update your dynamic IP through EditDNS’s API.
Requirements:
- You need to register first! (duh)
- Donations are optional, but if it makes your life easier you should consider it and you’ll also get more services.
- Perl!
File: editdns.pl
#!/usr/bin/perl
use strict;
## Configure ONLY this 2 variables
my $editdns_pass = "a"; # put your password
my $editdns_record = "b"; # put the record you wish to update
## ###############
## Nothing else should be changed unless you know what to do
## ###############
my $host = "DynDNS.EditDNS.net";
my $port = 80;
my $editdns_post = "p=$editdns_pass&r=$editdns_record";
my $editdns_req = join("",
"POST /api/dynLinux.php HTTP/1.0\r\n",
"Host: $host:$port\r\n",
"User-Agent: EditDNS Browser 0.1\r\n",
"Referer: http://www.editdns.net\r\n",
"Content-Type: application/x-www-form-urlencoded\r\n",
"Content-Length: ".length($editdns_post)."\r\n\r\n",
"$editdns_post\n"
);
my $hostaddr = (gethostbyname($host))[4] || &error("Couldn't get IP for $host");
my $remotehost= pack('S n a4 x8',2,$port,$hostaddr);
socket(S,2,1,6) || &error("Couldn't create socket");
connect(S,$remotehost) || &error("Couldn't connect to $host:$port");
select((select(S),$|=1)[0]);
print S $editdns_req;
vec(my $rin='',fileno(S),1)= 1 ;
select($rin,undef,undef,60) || &error("No response from $host:$port");
undef($/);
close(S);
print "[DONE]\n";
exit;
sub error {
print "[ERROR] $_[0]\n";
exit;
}
Next and once you have configured the script:
chmod +x editdns.pl
pico /etc/crontab
# Add editdns.pl to execute every 15 minutes
*/15 * * * * root /path/editdns.pl > /dev/null 2>&1
Do not set intervals lower than 15 minutes, since it can be considered as an abuse and you’ll get banned.
Part of this code was taken from James Marshal, happy coding!
*** If you are looking for SSL support and multiple records you might want to check http://xux.in/blog/post/php-editdns-updater-for-linux/
I’ve updaed your Perl script to include support for updating multple domains and log messages to syslog. You can find the updated script (and a PHP version as well) here:
http://forums.nerdie.net/showthread.php?t=616
@Jason: Thanks for sharing, I’ll update this post as soon as I have some spare time 😉
I’ve setup an personal SVN repository and Trac installation (with source browsing for public access) for the EditDNS scripts. I’m continuing to improve them, with the next planned feature being SSL support.
Any word on ssl support?
@xian: the idea of this script was to make it simple without using any library, however, for supporting SSL it will need more work, I’ll post later (within this week) a new perl and php version taking Jason’s ideas.
This is curious. Does EditDNS not require a username with the password. Is that right?
## Configure ONLY this 2 variables
my $editdns_pass = “a”; # put your password
my $editdns_record = “b”; # put the record you wish to update
It requires a password.