Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Added dynamic DNS support for DNSimple

    Scheduled Pinned Locked Moved DHCP and DNS
    3 Posts 2 Posters 1.4k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S Offline
      surrural
      last edited by

      I've submitted a pull request on github, but in case anyone is interested here's how to add dynamic dns support for dnsimple.com records:

      After editing the code, enter your DNSimple domain name for Hostname, Account API token for password, Record ID for ZoneID, and TTL.

      /etc/inc/services.inc
      Add dnsimple to the list of provider values and descriptions:

      define('DYNDNS_PROVIDER_VALUES', 'citynetwork cloudflare custom custom-v6 dhs dnsexit dnsimple dnsomatic dyndns dyndns-custom dyndns-static dyns easydns eurodns freedns gratisdns he-net he-net-v6 he-net-tunnelbroker loopia namecheap noip noip-free ods opendns ovh-dynhost route53 selfhost zoneedit');
      define('DYNDNS_PROVIDER_DESCRIPTIONS', 'City Network,CloudFlare,Custom,Custom (v6),DHS,DNSexit,DNSimple,DNS-O-Matic,DynDNS (dynamic),DynDNS (custom),DynDNS (static),DyNS,easyDNS,Euro Dns,freeDNS,GratisDNS,HE.net,HE.net (v6),HE.net Tunnelbroker,Loopia,Namecheap,No-IP,No-IP (free),ODS.org,OpenDNS,OVH DynHOST,Route 53,SelfHost,ZoneEdit');
      
      

      /usr/local/www/services_dyndns_edit.php
      In function _onTypeChange(type) add case "dnsimple": just below case "route53" to unhide the needed HTML elements:

      ...
      case "route53":
      case "dnsimple":
      	document.getElementById("_resulttr").style.display = 'none';
      	document.getElementById("_urltr").style.display = 'none';
      ...
      
      

      /etc/inc/dyndns.class
      In if ($forceUpdate == false && $this->_detectChange() == false) add case "dnsimple": to the same list of all the other providers:

      ...
      case 'citynetwork':
      case 'dnsimple':
      	$this->_update();
      	if($this->_dnsDummyUpdateDone == true) {
      ...
      

      In function _update() … switch ($this->_dnsService) add:

      ...
      case 'dnsimple':
      	/* Uses DNSimple's REST API
      	   Requires username and Account API token passed in header
      	   Piggybacks on Route 53's ZoneID field for DNSimple record ID
      	   Data sent as JSON */
      	$needsIP = TRUE;
      	$server = 'https://api.dnsimple.com/v1/domains/';
      	$token = $this->_dnsUser . ':' . $this->_dnsPass;
      	$jsondata = '{"record":{"content":"' . $this->_dnsIP . '","ttl":"' . $this->_dnsTTL . '"}}';
      	curl_setopt($ch, CURLOPT_HEADER, 1);
      	curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
      	curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json','Content-Type: application/json','X-DNSimple-Token: ' . $token));
      	curl_setopt($ch, CURLOPT_URL, $server . $this->_dnsHost . '/records/' . $this->_dnsZoneID);
      	curl_setopt($ch, CURLOPT_POSTFIELDS, $jsondata);
      	break;
      ...
      

      In function _checkStatus($ch, $data) … switch ($this->_dnsService) add:

      ...
      case 'dnsimple':
      	/* Responds with HTTP 200 on success.
      	   Responds with HTTP 4xx on error.
      	   Returns JSON data as body */
      	$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
      	$header = substr($data, 0, $header_size);
      	$body = substr($data, $header_size);
      	if (preg_match("/Status: 200\s/i", $header)) {
      		$status = "phpDynDNS ({$this->_dnsHost}): (Success) IP Address Updated Successfully!";
      		$successful_update = true;
      	} else if (preg_match("/Status: 4\d\d\s/i", $header)) {
      		$arrbody = json_decode($body, true);
      		$message = $arrbody['message'] . ".";
      		if (isset($arrbody['errors']['content'])) {
      			foreach($arrbody['errors']['content'] as $key => $content) {
      				$message .= " " . $content . ".";
      			}
      		}
      		$status = "phpDynDNS ({$this->_dnsHost}): (Error) " . $message;
      	} else {
      		$status = "phpDynDNS ({$this->_dnsHost}): (Unknown Response)";
      		log_error("phpDynDNS ({$this->_dnsHost}): PAYLOAD: {$body}");
      		$this->_debug($body);
      	}
      	break;
      ...
      
      1 Reply Last reply Reply Quote 0
      • D Offline
        doktornotor Banned
        last edited by

        Can't you just link the pull request so that everyone interested can apply it via the System Patches package, instead of manual error-prone messing with loads of files?

        1 Reply Last reply Reply Quote 0
        • S Offline
          surrural
          last edited by

          Ha! Sorry, my first time using github. Here's the link:

          https://github.com/pfsense/pfsense/pull/1479

          1 Reply Last reply Reply Quote 0
          • First post
            Last post
          Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.