Did you know we have a DNS API?


Seems some cool features get lost, and only staff know about them rather than the customers. I thought I’d point out to people we have an API for our DNS.
This can be used by scripts for adding domains to your own VPS using PHP curl, or similar other things. Another excellent use is fail over, set up a script that calls a DNS change should your server be non-responsive!

Also can be used for Dyndns of course if you want to have home.yourdomain.com etc. The full rundown of commands and calls can be found at https://rimuhosting.com/dns/dyndns.jsp

Here’s a quick overview and script

#!/bin/bash 
APIKEY="yourapikey from https://rimuhosting.com/cp/apikeys.jsp" 
DOMAIN=$1 
IP=ip.of.your.vps

if [ "$DOMAIN" = "" ]; then 
    echo "Error: no domain specified."; 
    exit 0;
 fi 

echo Adding domain $DOMAIN 
#Add Zone 
/usr/bin/curl --data "api_key=$APIKEY&name=$DOMAIN" http://rimuhosting.com/dns/addzone.jsp >> /var/log/newdomain.log 2>&1 
#Add A Records for domain and www.domain 
/usr/bin/curl --data "api_key=$APIKEY&action=SET&name=$DOMAIN&type=A&value=$IP" https://rimuhosting.com/dns/dyndns.jsp >> /var/log/newdomain.log 2>&1 
/usr/bin/curl --data "api_key=$APIKEY&action=SET&name=www.$DOMAIN&type=A&value=$IP" https://rimuhosting.com/dns/dyndns.jsp >> /var/log/newdomain.log 2>&1 
/usr/bin/curl --data "api_key=$APIKEY&action=SET&name=mail.$DOMAIN&type=A&value=$IP" https://rimuhosting.com/dns/dyndns.jsp >> /var/log/newdomain.log 2>&1 
/usr/bin/curl --data "api_key=$APIKEY&action=SET&name=ftp.$DOMAIN&type=A&value=$IP" https://rimuhosting.com/dns/dyndns.jsp >> /var/log/newdomain.log 2>&1 

Put that into something like adddomain.sh, then chmod +x adddomain.sh ; ./adddomain.sh newdomain.sh
If you had a text file with a list of domains you can do something like this

cat domains.txt | while read domain ; do ./adddomain.sh $domain ; done 

Our API does not have the functionality to delete domains or add slave domains only, this is in the pipeline however for the very near future.


One response to “Did you know we have a DNS API?”

  1. Thanks Liz, looking forward to the ability to be able to delete zones and convert to slave. At the moment this is a manual process for us.