Welcome, Guest. Please login or register.
Did you miss your activation email?
+  pfSense Forum
|-+  pfSense English Support» DHCP and DNS» DNS-O-Matic patch for 1.2.3-Release
Username:
Password:
 
 

Pages: [1] 2  All   Go Down
  Print  
Author Topic: DNS-O-Matic patch for 1.2.3-Release  (Read 1855 times)
0 Members and 1 Guest are viewing this topic.
vynce
Newbie
*
Offline Offline

Posts: 12


View Profile
« on: December 14, 2009, 02:26:41 am »

I've merged the DNS-O-Matic (dnsomatic) changes that were posted here into the final 1.2.3 release. Here is how to apply the attached patch on an embedded system from a Linux/Unix/OS X system (applying the patch to a regular install will probably be similar and you can likely omit the remount commands):

Green commands are executed on the host.
Blue commands are executed on the pfSense box.

  • Download the attached patch and remove the .txt from the end of the filename.
  • ssh into your router:
      ssh admin@192.168.1.1
  • Select option 8 to get to a shell.
  • Remount the filesystem read/write:
      /etc/rc.conf_mount_rw
  • Open another terminal and scp the patch onto your router:
      scp dnsomatic_1.2.3.patch root@192.168.1.1:/root/
  • Apply the patch. A backup of the two patched files will automatically be made with the .orig extension.
      patch -p -i /root/dnsomatic_1.2.3.patch
  • Remount the filesystem read-only:
      /etc/rc.conf_mount_ro

If you ever need to undo the patch just perform the same sequence of commands, but add the R flag to the patch command like this:
  patch -Rp -i /root/dnsomatic_1.2.3.patch
or restore the backups:
  cp /etc/inc/dyndns.class{.orig,}
  cp /usr/local/www/services_dyndns.php{.orig,}

« Last Edit: December 23, 2009, 07:42:41 pm by vynce » Logged
fenris
Newbie
*
Offline Offline

Posts: 3


View Profile
« Reply #1 on: December 22, 2009, 06:12:58 pm »

vynce,

I tried to follow the steps, but when I scp the file to my box it doesn't show up in the file system when I ls.

I am running the following so that I get in as admin:
scp dnsomatic_1.2.3.patch admin@192.168.0.1:~/

I didn't run the patch command as I couldn't find the file. Am I supposed to just type the commands as is?
Logged
vynce
Newbie
*
Offline Offline

Posts: 12


View Profile
« Reply #2 on: December 22, 2009, 11:24:18 pm »

Your scp command is correct. I've updated my instructions above to include the username in the scp command. The patch should get copied to the admin home directory on the router. Once you've ssh'ed into the router, try typing 'cd' without a path to change to the admin home directory. If you then do an 'ls' and don't see the patch, then it wasn't copied over successfully. The patch file needs to be present on the router for the patch command to work, so checking that the patch actually copied over successfully, like you were doing, is a good idea.

I think some of the steps in my instructions may need to be reordered. Try remounting the filesystem read/write (step 5) before doing the scp. I'm going to be applying this patch to another box in the next day or two and will verify all of the steps then.
Logged
vynce
Newbie
*
Offline Offline

Posts: 12


View Profile
« Reply #3 on: December 23, 2009, 07:46:56 pm »

Ok, I've fixed the instructions. There were two things wrong. The ordering of the steps needed to be changed so that the filesystem was remounted read/write before scp'ing, and the patch needed to be scp'ed as the root user instead of the admin user. Let me know if it works for you now.
Logged
fenris
Newbie
*
Offline Offline

Posts: 3


View Profile
« Reply #4 on: December 26, 2009, 02:04:07 pm »

Confirmed - the steps now work.
Logged
keithalbert
Newbie
*
Offline Offline

Posts: 4


View Profile
« Reply #5 on: February 06, 2010, 03:20:15 pm »

Should these steps work on the embeded nanobsd 1.2.3 release?
I am getting the following error when I attempt to run the patch command.

[root@pfsense.local]/root(12): patch -p -i /root/dnsomatic_1.2.3.patch
Hmm...  Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|--- /etc/inc/dyndns.class   2009-12-07 18:40:27.000000000 -0600
|+++ /etc/inc/dyndns.class      2009-12-13 23:29:18.000000000 -0600
--------------------------
Patching file /etc/inc/dyndns.class using Plan A...
Hunk #1 failed at 117.
Hunk #2 failed at 374.
Hunk #3 failed at 418.
3 out of 3 hunks failed--saving rejects to /etc/inc/dyndns.class.rej
Hmm...  The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|--- /usr/local/www/services_dyndns.php 2009-12-07 18:40:27.000000000 -0600
|+++ /usr/local/www/services_dyndns.php 2009-12-13 23:31:02.000000000 -0600
--------------------------
Patching file /usr/local/www/services_dyndns.php using Plan A...
Hunk #1 failed at 179.
1 out of 1 hunks failed--saving rejects to /usr/local/www/services_dyndns.php.rej
done
Logged
vynce
Newbie
*
Offline Offline

Posts: 12


View Profile
« Reply #6 on: February 06, 2010, 04:45:18 pm »

Yes, it should work on the embedded version; that's what I'm using. I actually haven't tested it on the full installed version.

I don't know why it's failing. Maybe you've already applied the patch or otherwise modified those files (?) -- if you try to apply the patch twice in a row, it will fail the second time. You could try to undo the patch using the instructions at the end of my original post and the reapply it. If it still fails, post the contents of the .rej files (cat /etc/inc/dyndns.class.rej, etc...) and maybe we can tell what's going on from that.
Logged
keithalbert
Newbie
*
Offline Offline

Posts: 4


View Profile
« Reply #7 on: February 06, 2010, 05:35:33 pm »

This was my first attempt to use the patch on a new install.  I have squid and squidguard installed if this might affect anything.  I did not modify any files directly on the router prior to trying the patch.

Here is the contents of the .rej file:

Thanks in advace!


***************
*** 117,123 ****
           if ($this->_detectChange() == FALSE) {
              $this->_error(10);
           } else {
-             if ($this->_dnsService == 'dyndns' ||
                 $this->_dnsService == 'dyndns-static' ||
                 $this->_dnsService == 'dyndns-custom' ||
                 $this->_dnsService == 'dhs' ||
--- 117,124 ----
           if ($this->_detectChange() == FALSE) {
              $this->_error(10);
           } else {
+             if ($this->_dnsService == 'dnsomatic' ||
+                $this->_dnsService == 'dyndns' ||
                 $this->_dnsService == 'dyndns-static' ||
                 $this->_dnsService == 'dyndns-custom' ||
                 $this->_dnsService == 'dhs' ||
***************
*** 373,386 ****
                 curl_close($ch);
                 $this->_checkStatus($data);
                 break;
-                                 case 'staticcling':
-                                         $needsIP = FALSE;
-                                         curl_setopt($ch, CURLOPT_URL, 'http://www.staticcling.org/update.html?login='.$this->_dnsUser.'&pass='.$this->_dnsPass);
-                                         $data = curl_exec($ch);
-                                         if (@curl_error($ch)) log_error("Curl error occured: " . curl_error($ch));
-                                         curl_close($ch);
-                                         $this->_checkStatus($data);
-                                         break;
              default:
                 break;
           }
--- 374,409 ----
                 curl_close($ch);
                 $this->_checkStatus($data);
                 break;
+                case 'staticcling':
+                     $needsIP = FALSE;
+                     curl_setopt($ch, CURLOPT_URL, 'http://www.staticcling.org/update.html?login='.$this->_dnsUser.'&pass='.$this->_dnsPass);
+                     $data = curl_exec($ch);
+                     if (@curl_error($ch)) log_error("Curl error occured: " . curl_error($ch));
+                     curl_close($ch);
+                     $this->_checkStatus($data);
+                     break;                      
+             case 'dnsomatic':
+             
+                /* Example syntax
+                   https://username:password@updates.dnsomatic.com/nic/update?hostname=yourhostname&myip=ipaddress&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG
+                */
+                
+                $needsIP = FALSE;
+                log_error("DNS-O-Matic: DNS update() starting.");
+                if (isset($this->_dnsWildcard) && $this->_dnsWildcard != "OFF") $this->_dnsWildcard = "ON";
+                curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
+                curl_setopt($ch, CURLOPT_USERPWD, $this->_dnsUser.':'.$this->_dnsPass);
+                $server = "https://" . $this->_dnsUser . ":" . $this->_dnsPass . "@updates.dnsomatic.com/nic/update?hostname=";
+                if($this->_dnsServer)
+                   $server = $this->_dnsServer;
+                if($this->_dnsPort)
+                   $port = ":" . $this->_dnsPort;
+                curl_setopt($ch, CURLOPT_URL, $server . $this->_dnsHost . '&myip=' . $this->_dnsIP . '&wildcard='.$this->_dnsWildcard . '&mx=' . $this->_dnsMX . '&backmx=NOCHG');
+                $data = curl_exec($ch);
+                if (@curl_error($ch)) log_error("Request completed. DNS-O-Matic reported: " . curl_error($ch));
+                curl_close($ch);
+                $this->_checkStatus($data);
+                break;
              default:
                 break;
           }
***************
*** 395,400 ****
           log_error("DynDns: Current Service: {$this->_dnsService}");
           $successful_update = false;
           switch ($this->_dnsService) {
              case 'dyndns':
                 if (preg_match('/notfqdn/i', $data)) {
                    $status = "phpDynDNS: (Error) Not A FQDN!";
--- 418,445 ----
           log_error("DynDns: Current Service: {$this->_dnsService}");
           $successful_update = false;
           switch ($this->_dnsService) {
+             case 'dnsomatic':
+                if (preg_match('/badauth/i', $data)) {
+                   $status = "DNS-O-Matic: The DNS-O-Matic username or password specified are incorrect. No updates will be distributed to services until this is resolved.";
+                } else if (preg_match('/notfqdn /i', $data)) {
+                   $status = "DNS-O-Matic: The hostname specified is not a fully-qualified domain name. If no hostnames included, notfqdn will be returned once.";
+                } else if (preg_match('/nohost/i', $data)) {
+                   $status = "DNS-O-Matic: The hostname passed could not be matched to any services configured. The service field will be blank in the return code.";
+                } else if (preg_match('/numhost/i', $data)) {
+                   $status = "DNS-O-Matic: You may update up to 20 hosts. numhost is returned if you try to update more than 20 or update a round-robin.";   
+                } else if (preg_match('/abuse/i', $data)) {
+                   $status = "DNS-O-Matic: The hostname is blocked for update abuse.";
+                } else if (preg_match('/good/i', $data)) {
+                   $status = "DNS-O-Matic: (Success) IP Address Changed Successfully! (".$this->_dnsIP.")";
+                   $successful_update = true;
+                } else if (preg_match('/dnserr/i', $data)) {
+                   $status = "DNS-O-Matic: DNS error encountered. Stop updating for 30 minutes.";
+                } else {
+                   $status = "DNS-O-Matic: (Unknown Response)";
+                   log_error("DNS-O-Matic: PAYLOAD: {$data}");
+                   $this->_debug($data);
+                }
+                break;
              case 'dyndns':
                 if (preg_match('/notfqdn/i', $data)) {
                    $status = "phpDynDNS: (Error) Not A FQDN!";
Logged
vynce
Newbie
*
Offline Offline

Posts: 12


View Profile
« Reply #8 on: February 06, 2010, 06:17:32 pm »

I wonder if squid/squidguard modify these files -- I can't think of any reason why they would. It looks like I'll need one more thing. Could you attach your dyndns.class and services_dyndns.php files? Here's how to copy them from the router to the current directory on your desktop:

scp root@192.168.1.1:/etc/inc/dyndns.class .
scp root@192.168.1.1:/usr/local/www/services_dyndns.php .
Logged
keithalbert
Newbie
*
Offline Offline

Posts: 4


View Profile
« Reply #9 on: February 07, 2010, 08:41:37 am »

files attached
Logged
vynce
Newbie
*
Offline Offline

Posts: 12


View Profile
« Reply #10 on: February 07, 2010, 05:18:45 pm »

The only difference between the files that you attached and the original pfSense ones is that yours have DOS line endings. This leads me to think that the problem is probably due to non-Unix line endings in the patch. Your web browser might have changed the line endings in the patch when it downloaded it because it thought that the patch was a text file.

There are two ways to fix the line endings. The first is to use a good text editor like Notepad++ to convert the line endings in the patch from DOS/Windows to Unix before scp'ing it to your pfSense box.

The other way is to convert the patch's line endings on your pfSense box. It was difficult finding a way to do this due to the limited utilities in pfSense, but this worked in my testing:

  awk '{ sub(/\r$/,""); print }' dnsomatic_1.2.3.patch > dnsomatic_1.2.3_fixed.patch

Then just use dnsomatic_1.2.3_fixed.patch in the patch command.
Logged
keithalbert
Newbie
*
Offline Offline

Posts: 4


View Profile
« Reply #11 on: February 08, 2010, 07:49:03 am »

Worked like a charm.  Thanks for the help.
Logged
vynce
Newbie
*
Offline Offline

Posts: 12


View Profile
« Reply #12 on: February 08, 2010, 07:50:51 pm »

Cool, I'm glad that worked. Smiley
Logged
david@indesignlondon.co.u
Newbie
*
Offline Offline

Posts: 11

i like rice


View Profile WWW
« Reply #13 on: March 02, 2010, 10:29:54 am »

Quote
here were two things wrong. The ordering of the steps needed to be changed so that the filesystem was remounted read/write before scp'ing, and the patch needed to be scp'ed as the root user instead of the admin user.

Works perfectly here too. Thanks. Smiley
Logged

------------------------
Live with passion
------------------------
CNLiberal
Newbie
*
Offline Offline

Posts: 2


View Profile
« Reply #14 on: March 02, 2010, 03:56:51 pm »

I'm very new to pfSense.  I have applied these patches.  They seemed to work fine.  There was no error.  However, now I want to enable the DNS-O-Matic server.  I have signed up for an account, but I don't know where/how in pfSense to add this.  What do I do?  I've tried going to:  Services:DynamicDNS Client but I don't know what settings to add.  Thanks!

Jim
Logged
Pages: [1] 2  All   Go Up
  Print  
 
Jump to:  

 

Page created in 0.194 seconds with 20 queries.