Dynamic DNS Option

CoMMy

New member
Joined
Jul 22, 2008
Messages
3
Hi,

Directadmin has a nice way of updating DNS zone records. I was wondering if it can be modified to be updated automatically like a Dynamic DNS server like all the free ones out there.

Basically user would be able to:

1) Create a zone record, either A or w/e.
2) Create a custom user/password for that record
3) User would call a custom PHP argument script or link found in pub_html folder that would tell DA to update zone YYY with XXX user and ZZZ pass.

Just my 2cents as a feature i would personally use if where available.

Thanks
 
Same here

as a hosting reseller, I find DA great to use (simple, clear and featured)

the Dynamic DNS feature request is about the only feature I'm missing, and very much wanted

L.
 
Last edited:
But DirectAdmin itself needs to be on the IP# in the license in order to keep running. So if you're using dyname IP# for some sites you still need static server IP#.

Jeff
 
But DirectAdmin itself needs to be on the IP# in the license in order to keep running. So if you're using dyname IP# for some sites you still need static server IP#.

Jeff
isn't the license tied to the 1 "shared" ip of the DA server and has nothing to do with whatever domain A record the client uses?
if I understand the request right (and I may be misreading it) its also something I have been looking for, I handle dns for some friends who run some security cams and stuff from their homes. when their isp changes the ip for THEM (the client in the OP) they have to log into DA and edit their A record.
routers have this built in to ping dyndns (or similar service) or they run a client app on pc update dyndns to update the A record, an app that could be run timed off their pc to compare and update the A record DA uses for their domain would be helpful.
 
I would be interested aswell instead using online dyndns service, actually, i do use the dlink one which is free for dlink hardware owner but ive been interested on this from long time, the only problem i see, is the creation of a software/service for windows/linux that interact with directadmin API (API itself are not definitly the problem).

If anyone have a solution please let me know.

Regards
 
I was able to implement that with the link you gave, thanks!

Now the problem is that DA isnt able to read .db file once nsupdate update the zone cause of template differences.

I did notice DA Staff about this hoping it will be fixed in future release, but beside that, it does work fine!

Regards
 
had looked at that link before too but was not comfortable enough with my skills to try.
 
It's a bit older request, but I would like something like this too. Any update on this in the mean time?
I also found a script here but since I'm no coder genius and the script is from 2012 I'm a bit scared to test it on a live server.
 
I've checked a bit the script you posted, but it doesnt look so good for me, it need to know the old ip, i think is more like a local webserver that call the remote DA server for an update.

A nice one would be a PHP script that get the IP from the client connected on HTTP protocol and "inform" DA via API's about the new IP for e defined zone authenticated via User/Pass.

Example: http://MYOWNDYNDNSSERVER/index.php?user=USERNAME?pass=PASSWORD?zone=myzone

The PHP script would use those information taking them from a DB for authenticate and autorize the user, and than use the DA API to delete old A record and create a new one with the new IP.

Regarding the older script posted by Kiekeboe100, as i wrote before, the script work fine, but there are few (major) issue:

1 - DA cant read the .jnl file so he cant read actual DNS and edit them for an entire zone
2 - Since DA cant read the zone, the multi-server setup will not be able to propagate that zone to slaves

Files:
rw-r--r-- 1 named named 852 Apr 30 2014 /var/named/dyndns.crazynetwork.it.db
-rw-r--r-- 1 named named 1.1K Dec 4 2013 /var/named/dyndns.crazynetwork.it.db.jnl

Zone transfer error:
Named::writeDB: error writing zone for dyndns.crazynetwork.it: email='' or ns1='' is empty. Ensure the zone is not corrupted.

>dig @localhost ufficio.dyndns.crazynetwork.it

; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.30.rc1.el6 <<>> @localhost ufficio.dyndns.crazynetwork.it
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 43371
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 3, ADDITIONAL: 3

;; QUESTION SECTION:
;ufficio.dyndns.crazynetwork.it. IN A

;; ANSWER SECTION:
ufficio.dyndns.crazynetwork.it. 300 IN A 93.63.162.59

;; AUTHORITY SECTION:
dyndns.crazynetwork.it. 3600 IN NS ns1.crazynetwork.it.
dyndns.crazynetwork.it. 3600 IN NS ns2.crazynetwork.it.
dyndns.crazynetwork.it. 3600 IN NS ns3.crazynetwork.it.

;; ADDITIONAL SECTION:
ns1.crazynetwork.it. 9821 IN A 93.63.162.56
ns2.crazynetwork.it. 2621 IN A 93.63.162.57
ns3.crazynetwork.it. 2621 IN A 77.43.71.14

;; Query time: 80 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Wed Dec 10 23:55:49 2014
;; MSG SIZE rcvd: 166

As you can see DA (and dataskq) "think" that the zone file is corrupted (while is not as you can see from dig command) and the zone is not transfered to slaves servers.

The implementation of the first script is pretty easy, can for sure be improoved on auth-side, but definitly a fix from DA Staff would be needed to be able to keep using DA to manage the zone and the Multi-Server function to propagate the zone to slave(s)

Regards
 
I've looked around and i did found the same script, after some research and testing i made a working one :)

It does use DA API, it DOES require httpsocket.php (you can find it here in the forum), i SUGGEST to use login keys with ONLY CMD_API_DNS_ADMIN access and i SUGGEST to protect with user/pass authentication the access to the URL (protect folder via DA Panel)

And here it is the script:

Code:
<?php

$DIRECTADMINUSER="admin";
$DIRECTADMINPASSWORD="LOGIN KEY - ONLY CMD_API_DNS_ADMIN";

include("httpsocket.php");

if (isset($_GET["hostname"])) {

  $IP = $_SERVER['REMOTE_ADDR'];
  $HOSTNAMEARRAY = explode(".", $_GET["hostname"]);
  $DOMAIN = $HOSTNAMEARRAY[1].".".$HOSTNAMEARRAY[2];
  $HOSTNAME = $HOSTNAMEARRAY[0];

  $ERROR=0;

  if ($IP !== gethostbyname($HOSTNAME)) {

    $sock = new HTTPSocket;
    $sock->connect("$DOMAIN",2222);
    $sock->set_login($DIRECTADMINUSER,$DIRECTADMINPASSWORD);
    $sock->set_method('POST');

    $sock->query("/CMD_API_DNS_ADMIN?domain=".$DOMAIN."&action=select&arecs0=name=".$HOSTNAME."&value=".gethostbyname("$HOSTNAME"));
    if (!strstr($sock->fetch_body(),"error=0")) $ERROR=1;
      $sock->query("/CMD_API_DNS_ADMIN?domain=".$DOMAIN."&action=add&type=A&name=".$HOSTNAME."&value=".$IP);
    if (!strstr($sock->fetch_body(),"error=0")) $ERROR=1;
    if ($ERROR == 0) print("DNS Updated"); else print ("DNS Update Error");

  }
  else print("nochg");
}
else print("notfqdn");

Everytime is called, it does remove the A zone and re-create it.

The hostname have to be passed this way:
Code:
http://yourwebsite/scriptname.php?hostname=whatever.dyn.yourdomain.tld

Ex:
Code:
http://dyn.domain.tld/index.php?hostname=sellerone.dyn.domain.tld

I hope this can be helpful to you all :)

Regards
 
Last edited:
Since the PHP script i posted pretended to use admin user and admin API's, i've edited it back to the original since it also set TTL to 60 seconds and is more secure.

The one i posted allow edit DNS for all domains present on the server, this one can change DNS just for the user owned domain.

In this script the user is set to dyndns, feel free to change it in a prefer way.

Also you will check a //$DOMAIN line, that line is for who use whatever.dyndns.domain.tld, the one uncommented is for whatever.dyndnsdomain.tld

Code:
<?php

$DIRECTADMINUSER="dyndns";
$DIRECTADMINPASSWORD="MYLOGINKEY - ONLY CMD_API_DNS_CONTROL";

include("httpsocket.php");

if (isset($_GET["hostname"])) {

  $IP = $_SERVER['REMOTE_ADDR'];
  $HOSTNAMEARRAY = explode(".", $_GET["hostname"]);
  $DOMAIN = $HOSTNAMEARRAY[1].".".$HOSTNAMEARRAY[2];
//$DOMAIN = $HOSTNAMEARRAY[1].".".$HOSTNAMEARRAY[2].".".$HOSTNAMEARRAY[3];
  $HOSTNAME = $HOSTNAMEARRAY[0];
  $ERROR=0;

  if ($IP !== gethostbyname($HOSTNAME)) {

    $sock = new HTTPSocket;
    $sock->connect("$DOMAIN",2222);
    $sock->set_login($DIRECTADMINUSER,$DIRECTADMINPASSWORD);
    $sock->set_method('POST');

    // Set TTL to 60 seconds
    $sock->query("/CMD_API_DNS_CONTROL?domain=".$DOMAIN."&action=ttl&ttl_select=custom&ttl=60");
    if (!strstr($sock->fetch_body(),"error=0")) $ERROR=1;
    // Remove old A record
    $sock->query("/CMD_API_DNS_CONTROL?domain=".$DOMAIN."&action=select&arecs0=name=".$HOSTNAME."&value=".gethostbyname("$HOSTNAME"));
    if (!strstr($sock->fetch_body(),"error=0")) $ERROR=1;
    // Create new A record
    $sock->query("/CMD_API_DNS_CONTROL?domain=".$DOMAIN."&action=add&type=A&name=".$HOSTNAME."&value=".$IP);
    if (!strstr($sock->fetch_body(),"error=0")) $ERROR=1;
    if ($ERROR == 0) print("DNS Updated"); else print ("DNS Update Error");

  }
  else print("nochg");
}
else print("notfqdn");

Regards
 
That's even better. But there's just something which I was thinking about.
The only difference with something like dyndns and no-ip is that they can maken different users for different subdomains.
Like user1 can have whatever.dyndnsdomain.tld and user2 can control the dns of someother.dyndnsdomain.tld and user3 has number3.dyndnsdomain.tld, all with their own login to manage their own subdomain DNS.

I presume something like that is a lot more difficult to make? Because of the DA structure?
 
Is not because of DA structure, it has nothing to do with that...

I would like to acchieve exactly what you are talking about, but for that i think that a MySQL (or MariaDB) Database will be needed.

The DB will have, user, password, owned-host(s)

So, the URL will need to be called differently (depending if POSTING data or not) and may look like this:
Code:
http://dyn.domain.tld/index.php?user=myuser?password=myuserpassword?hostname=mycustom.dyn.domain.tld

I'm not a PHP programmer, and actually i should test something but will require a little of study from me about PHP-MySQL connection/query, someone with a PHP-MySQL competence will do that in 5 minutes i presume...

Sayd that, the script will just took those 3 information, ask the DB if the user/pass combination is correct and than check if the user have the privilege for a specified hostname, if yes, it goes to step2 (the script i've already posted), if not, just reject the query and show an error.

Once this is working fine, the 3rd step would be a windows/linux(not that needed, can be accomplishied with a crontab)/mac(not that needed aswell, can be accomplishied with a crontab) client that once every 10min (or 30 or 60 or whatever) call that URL with pre-configured user/pass/host combination to update the DNS record.

Regards
 
Is not because of DA structure, it has nothing to do with that...
Why not? Because in the DA structure you need a user account for every domain. As far as I've seen you can't setup a useraccount for every subdomain.
But since you know more about it then me, I guess there is a way to do that too. :)
Indeed if you could do it with a database like you say, it should be possible.

Darn... pity i don't know anything of scripting, can only read it a little bit. I would gladly make a php script for that if I was able to program in php.
 
Back
Top