Yes, I did. Due to another issue (see AAAA record got lost) I have my records checked periodically - not via the REST API, but with cyclic “dig @nsX.dynv6.com” where X in (1,2,3).
If the dig fails then the corresponding record is restored via the REST API.
It appears however that the API doesn’t always reflect the actual status of the NS.
From time to time this results in duplicate records. So I’ve created a shell script that checks for duplicates and deletes the most recent one(s), if present.
Here’s the script:
#!/bin/bash
# remove duplicate records from server
# requires jq to be installed
# settings
TOKEN=abcdefghijklmnopqrstuvwxyz1234
ZONEID=1234567
if [ X != X$1 ]
then
ZONEID=$1
fi
TEMPFILE=/tmp/dynv6_$ZONEID.tmp
RECORDS_A=('louie' 'huey' 'dewey' 'foo' 'bar')
RECORDS_AAAA=('louie' 'huey' 'dewey' 'foo' 'bar' '')
DATA_MX='mail'
PRIO_MX=10
TYPES=('A' 'AAAA' 'MX')
# determine current status
curl -sS --fail \
-H "Authorization: Bearer $TOKEN" \
-H "Accept: application/json" \
https://dynv6.com/api/v2/zones/$ZONEID/records \
> $TEMPFILE
for TYPE in "${TYPES[@]}"
do
for NAME in "${RECORDS_AAAA[@]}"
do
ID=$( jq 'map (select(.type=="'$TYPE'") | select(.name=="'$NAME'")) | .[].id' "$TEMPFILE") # contains all IDs for a specific record
NUM_IDS=`echo $ID | wc -w` # how many IDs exist for this record?
while [ $NUM_IDS -gt 1 ]
do # remove redundant
LATEST_ID=$( echo $ID | gawk '{print $(NF)}' ) # get last ID...
echo `date --rfc-3339=seconds` "deleting duplicate record '$TYPE' '$NAME' $LATEST_ID"
ID=${ID//$LATEST_ID/ } # ...and remove it from the list (just replace with empty string)
NUM_IDS=`echo $ID | wc -w`
curl -sS --fail \
-X DELETE \
-H "Authorization: Bearer $TOKEN" \
-H "Accept: application/json" \
https://dynv6.com/api/v2/zones/$ZONEID/records/$LATEST_ID # remove record
done
done
done
rm $TEMPFILE
Hope this helps!
Thomas