PHP EditDNS Updater for Linux

This is a simple PHP script which will update your dynamic DNS records using EditDNS.

– You can configure as many records as you want.
– Supports HTTP and HTTPS.
– For PHP 4x and higher compiled with sockets.
– Simple validation.

Here is the code: (editdns.php)

#!/usr/bin/php -q

$port = 443; // use 80 if you dont wanna use SSL
// add as many arrays as you want, first element is the record
// and the second is the password
// $data[] = array('','mypass1');
// $data[] = array('','mypass2');
// ... etc etc etc ;)
$data[] = array('','blahblah123');
$sleep = 1; // seconds we should sleep before updating another record

// main loop
if (!is_array($data)) die("Nothing to do\n");
foreach ($data as $v) {
  echo "Updating $v[0] ... ";
  if(_send($port,"p=$v[1]&r=$v[0]")) echo "[OK]\n";

function _send($port=443,$args="") {
  if ($port == 443) $proto = "ssl";
  else $proto = "http";
  $fp = fsockopen("$proto://",$port,$errno,$errstr,10);
  if (!$fp) die("\nCouldn't establish connection\n");
  $out = "POST /api/dynLinux.php HTTP/1.0\r\n";
  $out .= "Host:\r\n";
  $out .= "Content-Type: application/x-www-form-urlencoded\r\n";
  $out .= "Content-Length: ".strlen($args)."\r\n";
  $out .= "Connection: Close\r\n\r\n";
  $out .= $args;
  //echo $out;
  fwrite($fp, $out);
  while (!feof($fp)) {
    $res .= fgets($fp,1024);
  $parts = explode("\r\n\r\n",trim($res));
  // checking output
  if (preg_match("/record has been updated|record already exists/i",$parts[1])) return 1;
  // anything else should be an error
  echo "[ERROR]\n\t$parts[1]\n";
  return 0;


Save it, chmod +x and play with it.

Old sources:

IP updater for

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.


  • 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!



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 = "";
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",
  "Content-Type: application/x-www-form-urlencoded\r\n",
  "Content-Length: ".length($editdns_post)."\r\n\r\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");
print S $editdns_req;
vec(my $rin='',fileno(S),1)= 1 ;
select($rin,undef,undef,60) || &error("No response from $host:$port");
print "[DONE]\n";

sub error {
        print "[ERROR] $_[0]\n";

Next and once you have configured the script:

chmod +x
pico /etc/crontab
# Add to execute every 15 minutes
*/15 * * * * root /path/ > /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