Dynamic DNS support for Gandi LiveDNS?



  • Hello,

    Gandi.net supports updating DNS records using their API, both on their old DNS platform and their new LiveDNS platform. Would it be possible to support this in pfSense's dynamic DNS feature? A quick search found a few scripts that are supposed to do this for LiveDNS:

    https://github.com/Gandi/api-examples/blob/master/bash/livedns/mywanip.sh
    https://github.com/cavebeat/gandi-live-dns
    https://github.com/plut0nium/gandi-dynamic-livedns
    https://github.com/rmarchant/gandi-ddns

    Alternatively, I have very limited scripting and command line skills, but how realistic would it be to run one of these scripts on a pfSense machine, using whatever mechanism it is that triggers pfSense's built-in dynamic DNS clients to perform an update, to trigger the custom script?

    Thanks!



  • I am using this script with a cron entry.

    
    0 	* 	* 	* 	* 	root 	/usr/local/bin/gandi.sh
    
    

    I had to install bash since it doesnt come with FreeBSD. The downside is that it is not linked to WAN. You may want to look at this.

    –---------------------------------------------------------------------------------
    Second approach was to run nginx/php on a separate FreeBSD server. The script i used were

    
    $cat /usr/local/bin/mywanip4.sh
    
    #!/usr/local/bin/bash
    
    DOMAIN="mydomain.com"
    RECORD="myrecord"
    APIKEY="MYKEY"
    
    API="https://dns.api.gandi.net/api/v5/"
    
    IP4=$1
    
    if [[ -z "$IP4"  ]]; then
        echo "Something went wrong. Can not get your IP from WAN "
        exit 1
    fi
    
    if [[ ! -z "$IP4" ]]; then
        DATA='{"rrset_values": ["'$IP4'"]}'
        curl -s -XPUT -d "$DATA" \
            -H"X-Api-Key: $APIKEY" \
            -H"Content-Type: application/json" \
            "$API/domains/$DOMAIN/records/$RECORD/A"
    fi
    
    # cat /usr/local/www/nginx/gandi_update.php 
       if(isset($_GET['ip']) && filter_var($_GET['ip'], FILTER_VALIDATE_IP))
       {
          $output = shell_exec('./mywanip4.sh ' . $_GET['ip']);
          echo "OK";
       }
       else
          echo "FAIL";
    ?>
    
    

    I had to install php56-filter and bash packages on the FreeBSD server to make it work. The update URL was http://192.16.1.2/gandi_update.php?ip=%IP%




Log in to reply