w00kie / gandi-automatic-dns

A Bourne shell script to update Gandi.net zonefiles

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

gad

This script is intended to be used as a cron job to maintain the accuracy of multiple A records in Gandi.net zonefiles. External IP address discovery is done via a network interface (works on BSD, untested on anything else) or [OpenDNS] 1. This is compared to the value in the active version of the zonefile of each record in RECORD-NAMES. Using the rpc() function to update different types of DNS records or call other methods of Gandi's XML-RPC API should be fairly trivial.

Prerequisites

Your domain needs to be using a zone that you are allowed to edit. The default Gandi zone does not allow editing, so you must create a copy. There are instructions on Gandi's wiki to [create an editable zone] 2. You only need to perform the first two steps. There is a FAQ regarding this [here] 3.

Requirements

  • Bourne shell
  • OpenSSL

Command line usage

$ gad [-f] [-t] [-v] [-i EXT_IF] -a APIKEY -d EXAMPLE.COM -r "RECORD-NAMES"

-f: Force an update regardless of IP address discrepancy
-t: Create a new version of the zonefile but don't activate it
-v: Print some information to stdout even if a new zonefile isn't needed
-i: Use ifconfig instead of OpenDNS to determine external IP address

EXT_IF: The name of your external network interface
APIKEY: Your API key provided by Gandi
EXAMPLE.COM: The domain name whose active zonefile will be updated
RECORD-NAMES: A space-separated list of the names of the A records to update or create

Request an API key from Gandi [here] 4.

rpc() syntax

rpc "methodName" "datatype" "value" "struct" "name" "datatype" "value"

This function can accept an arbitrary number of datatype/value pairs and structs and their member name/datatype/value tuples. structs must be last! Valid method names can be found in the [Gandi API documentation] 5. Note that the APIKEY value from the command line is automatically included as the first parameter.

About

A Bourne shell script to update Gandi.net zonefiles


Languages

Language:Shell 100.0%