PfSense 2.0.1 dynDNS for GratisDNS Service



  • If you, like I do, use GratisDNS (www.gratisdns.dk) to provide domain hosting and want to use their dynamic DNS service, I've written a little guide to get it set up and running with pfSense 2.0.1.

    The following files should be modified, either through SSH or through the Diagnostic -> Edit file function:

    \etc\inc\dyndns.class
    Before (=Original code)

    
    	 *  HE.net         - Last Tested: NEVER
    	 * +====================================================+
    
    

    After (=Modified code)

    
    	 *  HE.net         - Last Tested: NEVER
    	 *  GratisDNS      - Last Tested: 15 August 2012
    	 * +====================================================+
    
    

    Before (=Original code)

    
    				case 'he-net':
    					$this->_update();
    
    

    After (=Modified code)

    
    				case 'he-net':
    				case 'gratisdns':
    					$this->_update();
    
    

    Before (=Original code)

    
    				case 'he-net':
    					$needsIP = FALSE;
    					log_error("HE.net: DNS update() starting.");
    					$server = "https://dyn.dns.he.net/nic/update?";
    					curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    					curl_setopt($ch, CURLOPT_USERPWD, $this->_dnsHost . ':' . $this->_dnsPass);
    					curl_setopt($ch, CURLOPT_URL, $server . 'hostname=' . $this->_dnsHost);
    					break;
    				default:
    					break;
    
    

    After (=Modified code)

    
    				case 'he-net':
    					$needsIP = FALSE;
    					log_error("HE.net: DNS update() starting.");
    					$server = "https://dyn.dns.he.net/nic/update?";
    					curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    					curl_setopt($ch, CURLOPT_USERPWD, $this->_dnsHost . ':' . $this->_dnsPass);
    					curl_setopt($ch, CURLOPT_URL, $server . 'hostname=' . $this->_dnsHost);
    					break;
    				case 'gratisdns':
    					$needsIP = FALSE;
    					log_error("GratisDNS: DNS update() starting.");
    					$server = "https://ssl.gratisdns.dk/ddns.phtml";
    					curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    					list($hostname, $domain) = explode(".", $this->_dnsHost, 2);
    					curl_setopt($ch, CURLOPT_URL, $server . '?u=' . $this->_dnsUser . '&p=' . $this->_dnsPass . '&h=' . $this->_dnsHost . '&d=' . $domain);
    					break;
    				default:
    					break;
    
    

    Before (=Original code)

    
    				case 'he-net':
    					if (preg_match("/badip/i", $data)) {
    					        $status = "phpDynDNS: (Error) Bad Request - The IP provided was invalid.";
    					} else if (preg_match('/nohost/i', $data)) {
    					        $status = "phpDynDNS: (Error) Bad Request - A hostname was not provided.";
    					} else if (preg_match('/badauth/i', $data)) {
    					        $status = "phpDynDNS: (Error) Invalid username or password.";
    					} else if (preg_match('/good/i', $data)) {
    					        $status = "phpDynDNS: (Success) IP Address Updated Successfully!";
    					        $successful_update = true;
    					} else if (preg_match('/nochg/i', $data)) {
    							$status = "phpDynDNS: (Success) No Change In IP Address.";
    							$successful_update = true;
    					} else {
    					        $status = "phpDynDNS: (Unknown Response)";
    					        log_error("phpDynDNS: PAYLOAD: {$data}");
    					        $this->_debug($data);
    					}
    					break;
    			}
    
    			if($successful_update == true) {
    
    

    After (=Modified code)

    
    				case 'he-net':
    					if (preg_match("/badip/i", $data)) {
    					        $status = "phpDynDNS: (Error) Bad Request - The IP provided was invalid.";
    					} else if (preg_match('/nohost/i', $data)) {
    					        $status = "phpDynDNS: (Error) Bad Request - A hostname was not provided.";
    					} else if (preg_match('/badauth/i', $data)) {
    					        $status = "phpDynDNS: (Error) Invalid username or password.";
    					} else if (preg_match('/good/i', $data)) {
    					        $status = "phpDynDNS: (Success) IP Address Updated Successfully!";
    					        $successful_update = true;
    					} else if (preg_match('/nochg/i', $data)) {
    							$status = "phpDynDNS: (Success) No Change In IP Address.";
    							$successful_update = true;
    					} else {
    					        $status = "phpDynDNS: (Unknown Response)";
    					        log_error("phpDynDNS: PAYLOAD: {$data}");
    					        $this->_debug($data);
    					}
    					break;
    
    				case 'gratisdns':
    					if (preg_match('/Forkerte værdier/i', $data)) {
    					        $status = "phpDynDNS: (Error) Wrong values - Update could not be completed.";
    					} else if (preg_match('/Bruger login: Bruger eksistere ikke/i', $data)) {
    					        $status = "phpDynDNS: (Error) Unknown username - User does not exist.";
    					} else if (preg_match('/Bruger login: 1Fejl i kodeord/i', $data)) {
    					        $status = "phpDynDNS: (Error) Wrong password - Remember password is case sensitive.";
    					} else if (preg_match('/Domæne kan IKKE administreres af bruger/i', $data)) {
    					        $status = "phpDynDNS: (Error) User unable to administer the selected domain.";
    					} else if (preg_match('/OK/i', $data)) {
    					        $status = "phpDynDNS: (Success) IP Address Updated Successfully!";
    					        $successful_update = true;
    					} else {
    					        $status = "phpDynDNS: (Unknown Response)";
    					        log_error("phpDynDNS: PAYLOAD: {$data}");
    					        $this->_debug($data);
    					}
    					break;
    			}
    
    			if($successful_update == true) {
    
    

    \usr\local\www\services_dyndns.php
    Before @ line 117 (=Original code)

    
    					$types = explode(",", "DNS-O-Matic, DynDNS (dynamic),DynDNS (static),DynDNS (custom),DHS,DyNS,easyDNS,No-IP,ODS.org,ZoneEdit,Loopia,freeDNS, DNSexit, OpenDNS, Namecheap, HE.net");
    					$vals = explode(" ", "dnsomatic dyndns dyndns-static dyndns-custom dhs dyns easydns noip ods zoneedit loopia freedns dnsexit opendns namecheap he-net");
    
    

    After @ line 117 (=Modified code)

    
    					$types = explode(",", "DNS-O-Matic, DynDNS (dynamic),DynDNS (static),DynDNS (custom),DHS,DyNS,easyDNS,No-IP,ODS.org,ZoneEdit,Loopia,freeDNS, DNSexit, OpenDNS, Namecheap, HE.net, GratisDNS");
    					$vals = explode(" ", "dnsomatic dyndns dyndns-static dyndns-custom dhs dyns easydns noip ods zoneedit loopia freedns dnsexit opendns namecheap he-net gratisdns");
    
    

    \usr\local\www\services_dyndns_edit.php
    Before @ line 162 (=Original code)

    
    						$types = explode(",", "DNS-O-Matic, DynDNS (dynamic),DynDNS (static),DynDNS (custom),DHS,DyNS,easyDNS,No-IP,ODS.org,ZoneEdit,Loopia,freeDNS, DNSexit, OpenDNS, Namecheap, HE.net");
    						$vals = explode(" ", "dnsomatic dyndns dyndns-static dyndns-custom dhs dyns easydns noip ods zoneedit loopia freedns dnsexit opendns namecheap he-net");
    
    

    After @ line 162 (=Modified code)

    
    						$types = explode(",", "DNS-O-Matic, DynDNS (dynamic),DynDNS (static),DynDNS (custom),DHS,DyNS,easyDNS,No-IP,ODS.org,ZoneEdit,Loopia,freeDNS, DNSexit, OpenDNS, Namecheap, HE.net, GratisDNS");
    						$vals = explode(" ", "dnsomatic dyndns dyndns-static dyndns-custom dhs dyns easydns noip ods zoneedit loopia freedns dnsexit opendns namecheap he-net gratisdns");
    
    

    I hope people will find it useful.

    Best regards,
    Scavy



  • You can create a ticcket with patchfiles, than it will be implemented in next release.


Locked