Howto: setup Dynamic DNS with Loopia.se and freedns.afraid.org



  • I don't know if this is common knowlege but I've found a way to enable Dynamic DNS for loopia and freeDNS. This is how I did it. (Updated)

    Edit /usr/local/www/services_dyndns.php to match
    $types = explode(",", "DynDNS (dynamic),DynDNS (static),DynDNS (custom),DHS,DyNS,easyDNS,No-IP,ODS.org,ZoneEdit,Loopia,freeDNS");
    $vals = explode(" ", "dyndns dyndns-static dyndns-custom dhs dyns easydns noip ods zoneedit loopia freedns");

    Edit /etc/inc/dyndns.class
      /* –--------First remove the requirement of variable $dnUpdateURL for freedns and add requrement for $dnsHost----------- /
      /
    freedns needs this /
      /
    if (!$dnsUpdateURL) $this->_error(7);/
      /
    fix 4 pfsense /
      if (!$dnsHost) $this->_error(5);
      …...............
    /
    ----------Second fix a correct _dnsUpdateURL from fixed hostname and dnsHost---------- /
      case 'freedns':
      $needIP = FALSE;
                curl_setopt($ch, CURLOPT_URL, 'http://freedns.afraid.org/dynamic/update.php?'.$this->_dnsHost);
                /
    curl_setopt($ch, CURLOPT_URL, $this->_dnsUpdateURL); /
                $data = curl_exec($ch);
                if (@curl_error($ch)) log_error("Curl errror occured: " . curl_error($ch));
                curl_close($ch);
                $this->_checkStatus($data);
                break;
      …...............
    /
    ----------Third fix https for loopia---------- */
    curl_setopt($ch, CURLOPT_URL, 'https://dns.loopia.se/XDynDNSServer/XDynDNS.php?hostname='.$this->_dnsHost.'&myip='.$this->_dnsIP);

    Restart webGUI

    Go to the webgui and setup DynamicDNS

    For loopia just use your credentials
    For freeDNS
    Set Hostname to match your update string (the part after ? for example if my update url is http://freedns.afraid.org/dynamic/update.php?UmhJRATwTVRTTUlBQVhrM3oyNDoyMDA0NjUz my hostname would be UmhJRATwTVRTTUlBQVhrM3oyNDoyMDA0NjUz
    Set Username and Password to anything (You only need to set it to make it pass pfsense mandatory fields)

    That is it!
    Happy surfing  8)
    It would be nice to be able to choose loopia in the webgui in the future. ;)



  • Added my /etc/inc/dyndns.class and /usr/local/www/services_dyndns.php files. :)

    dyndns.class.txt
    services_dyndns.php.txt



  • Greate news!

    I have just started using loopias DNS service. Do you know how to check if this change works?

    /Urban



  • Test it by setting the ip manualy at loopia.se and then restart the service in pfsense. After that do a nslookup on your host or check the ip on loopia or just ask anybody to try and access your servers.



  • Works wery nice. Only drawback is that i manually have to edit this whenever i install anew version.

    Can this be included in the release?

    /UrbanSk



  • If anybody of you can provide a patch so we can easily integrate it and make it available in the next version ( http://devwiki.pfsense.org/SubmittingPatches ).





  • ran into an error …

    freedns uses some illegal characters for links such as ==
    this is not allowed in the edited script.
    Quickest workaround is to regenerate the link on freedns until the name is free of illegal characters



  • Wanted to thank you for posting these instructions.  I modified them and got DNS Made Easy working.  For anyone who is trying to do this, here's what I did.  Keep in mind, this is my first try, so I'm sure there is a better way.

    First, edit /usr/local/www/services_dyndns.php

    Add the entries in bold below.

    $types = explode(",", "DynDNS (dynamic),DynDNS (static),DynDNS (custom),DHS,DyNS,easyDNS,No-IP,ODS.org,ZoneEdit,Loopia,freeDNS, DNS Made Easy");
    $vals = explode(" ", "dyndns dyndns-static dyndns-custom dhs dyns easydns noip ods zoneedit loopia freedns dnsmadeeasy");

    Next, edit /etc/inc/dyndns.class and add some entries (bolded)

    if ($this->_dnsService == 'dyndns' ||
    $this->_dnsService == 'dyndns-static' ||
    $this->_dnsService == 'dyndns-custom' ||
    $this->_dnsService == 'dhs' ||
    $this->_dnsService == 'noip' ||
    $this->_dnsService == 'easydns' ||
    $this->_dnsService == 'hn' ||
    $this->_dnsService == 'zoneedit' ||
    $this->_dnsService == 'dyns' ||
    $this->_dnsService == 'ods' ||
    $this->_dnsService == 'freedns' ||
    $this->_dnsService == 'loopia' ||
    $this->_dnsService == 'dnsmadeeasy' ||
    $this->_dnsService == 'staticcling')

    Also make this change (same file).  I inserted it under the loopia entry.

    case 'loopia':
    $needsIP = TRUE;
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_USERPWD, $this->_dnsUser.':'.$this->_dnsPass);
    curl_setopt($ch, CURLOPT_URL, 'https://dns.loopia.se/XDynDNSServer/XDynDNS.php?hostname='.$this->_dnsHost.'&myip='.$this->_dnsIP);
    $data = curl_exec($ch);
    if (@curl_error($ch)) log_error("Curl error occurred: " . curl_error($ch));
    curl_close($ch);
    $this->_checkStatus($data);
    break;
                     
    **                                    case 'dnsmadeeasy':
                                            $needsIP = TRUE;
                                            $server = "https://www.dnsmadeeasy.com/servlet/updateip?";
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
                                            curl_setopt($ch, CURLOPT_USERPWD, $this->_dnsUser.':'.$this->_dnsPass);
    curl_setopt($ch, CURLOPT_URL, $server.'username='.$this->_dnsUser.'&password='.$this->_dnsPass.'&id='.$this->_dnsHost.'&ip='.$this->_dnsIP);
                                            $data = curl_exec($ch);
                                            if (@curl_error($ch)) log_error("Curl error occurred: " . curl_error($ch));
                                            curl_close($ch);
                                            $this->_checkStatus($data);
                                            break;**

    And this change (same file).  I put it under loopia again

    case 'loopia':
    if (preg_match("/nochg/i", $data)) {
    $status = "phpDynDNS: (Success) No Change In IP Address";
    $successful_update = true;
    } else if (preg_match("/good/i", $data)) {
    $status = "phpDynDNS: (Success) IP Address Changed Successfully!";
    $successful_update = true;
    } else if (preg_match('/badauth/i', $data)) {
    $status = "phpDynDNS: (Error) User Authorization Failed";
    } else {
    $status = "phpDynDNS: (Unknown Response)";
    log_error("phpDynDNS: PAYLOAD: {$data}");
    $this->_debug($data);
    }
    break;
    case 'dnsmadeeasy':
                                            if (preg_match("/nochg/i", $data)) {
                                                    $status = "phpDynDNS: (Success) No Change In IP Address";
                                                    $successful_update = true;
                                            } else if (preg_match("/good/i", $data)) {
                                                    $status = "phpDynDNS: (Success) IP Address Changed Successfully!";
                                                    $successful_update = true;
                                            } else if (preg_match('/badauth/i', $data)) {
                                                    $status = "phpDynDNS: (Error) User Authorization Failed";
                                            } else {
                                                    $status = "phpDynDNS: (Unknown Response)";
                                                    log_error("phpDynDNS: PAYLOAD: {$data}");
                                                    $this->_debug($data);
                                            }
                                            break;

    Reload the web configurator and DNS Made Easy will now be listed.  In the hostname, put your Record ID in the HostName field for the particular record you want updated.  Mine is a 7 digit number, so I suspect that is the standard for them.

    Put in your username and password in the corresponding fields and you should be good.


Log in to reply