Project

General

Profile

Actions

Bug #3973

closed

Route 53 dynamic DNS provider fails to update record

Added by Grant Horning over 9 years ago. Updated about 7 years ago.

Status:
Resolved
Priority:
High
Category:
Dynamic DNS
Target version:
Start date:
11/02/2014
Due date:
% Done:

0%

Estimated time:
Plus Target Version:
Release Notes:
Affected Version:
2.3.x
Affected Architecture:

Description

Existing records are not updating with the Route 53 dynamic DNS provider.

Records that do not exist are created properly, but then pfSense fails to update the record.

I found these errors in /tmp/PHP_errors.log, but there was no indication of failure in the system log or DynDNS page.

[02-Nov-2014 13:34:42 America/Denver] PHP Warning: Route53::changeResourceRecordSets(): Sender - InvalidChangeBatch: Tried to create resource record set [name='example.domain.org.', type='A'] but it already exists
Request Id: <removed>
in /etc/inc/r53.class on line 545

[02-Nov-2014 13:36:53 America/Denver] PHP Warning: Route53::changeResourceRecordSets(): Sender - InvalidChangeBatch: RRSet with DNS name example. is not permitted in zone domain.org.
Request Id: <removed>
in /etc/inc/r53.class on line 545


There have been several changes to the AWS Route 53 API since this class was implemented. The following files must be updated to fix this issue:

/etc/inc/r53.class
/etc/inc/dyndns.class

Issue #1:

The latest AWS API requires that a FQDN must be used. (Eg. "example.domain.org." rather than "example.").

Issue #2

Instead of using the CREATE/DELETE API actions, UPSERT may be used to reduce code complexity.

http://docs.aws.amazon.com/Route53/latest/APIReference/API_ChangeResourceRecordSets_Requests.html

Actions #1

Updated by Jim Riggs almost 9 years ago

Here is the patch I am using with the System Patches package to work around this issue in 2.1:

--- /etc/inc/dyndns.class.orig    2015-06-05 08:14:09.000000000 -0500
+++ /etc/inc/dyndns.class    2015-06-05 08:18:00.000000000 -0500
@@ -538,44 +538,9 @@

                     /* Set Amazon AWS Credentials for this record */
                     $r53 = new Route53($AccessKeyId, $SecretAccessKey);
+                    $changes = $r53->prepareChange('UPSERT', $hostname, 'A', $NewTTL, $NewIP);
+                    $result = $r53->changeResourceRecordSets("/hostedzone/$ZoneID", $changes);

-                    /* Function to find old values of records in Route 53 */
-                    if(!function_exists('Searchrecords')) {
-                        function SearchRecords($records, $name) {
-                            $result = array();
-                            foreach($records as $record) {
-                                if(strtolower($record['Name']) == strtolower($name)) {
-                                    $result [] = $record;
-                                }
-                            }
-                            return ($result) ? $result : false;
-                        }
-                    }
-
-                    $records = $r53->listResourceRecordSets("/hostedzone/$ZoneID");
-
-                    /* Get IP for your hostname in Route 53 */
-                    if(false !== ($a_result = SearchRecords($records['ResourceRecordSets'], "$hostname"))) {
-                        $OldTTL=$a_result[0][TTL];
-                        $OldIP=$a_result[0][ResourceRecords][0];
-                    } else {
-                        $OldIP="";
-                    }
-
-                    /* Check if we need to update DNS Record */
-                    if ($OldIP !== $NewIP) {
-                        if(!empty($OldIP)) {
-                            /* Your Hostname already exists, deleting and creating it again */
-                            $changes = array();
-                            $changes[] = $r53->prepareChange(DELETE, $hostname, A, $OldTTL, $OldIP);
-                            $changes[] = $r53->prepareChange(CREATE, $hostname, A, $NewTTL, $NewIP);
-                            $result = $r53->changeResourceRecordSets("/hostedzone/$ZoneID", $changes);
-                        } else {
-                            /* Your Hostname does not exist yet, creating it */
-                            $changes = $r53->prepareChange(CREATE, $hostname, A, $NewTTL, $NewIP);
-                            $result = $r53->changeResourceRecordSets("/hostedzone/$ZoneID", $changes);
-                        }
-                    }
                     $this->_checkStatus(0, $result);
                     break;
                 case 'custom':
Actions #2

Updated by Chris Buechler over 8 years ago

  • Category set to Dynamic DNS
Actions #3

Updated by Matt Williams over 7 years ago

Jim,

Did you (or anyone) every submit a commit to correct this? I know it becomes problematic when the TTL changes, but I would like to work on submitting this to have it included with the master branch. Also looking to add some geo features with that change. Thoughts?

M

Actions #4

Updated by Renato Botelho over 7 years ago

  • Status changed from New to Feedback
  • Assignee set to Renato Botelho
  • Target version set to 2.4.0

Please check next round of 2.3.3 or 2.4.0 snapshots to make sure issue persists with current code

Actions #5

Updated by Jason McCormick over 7 years ago

The use of the UPCERT action in 6751 should address this bug.

Actions #6

Updated by Jim Pingle about 7 years ago

  • Status changed from Feedback to Resolved

Tested Route53, it updates records properly now.

Actions #7

Updated by Jim Pingle about 7 years ago

  • Target version changed from 2.4.0 to 2.3.3
  • Affected Version set to 2.3.x
Actions

Also available in: Atom PDF