Tuesday, 29 April 2014

Update your Domain Name (DNS) with a Dynamic IP and Amazon Route 53

Note: works also on a QNAP NAS

  • Install Python and pip (for QNAP you can find a how-to here).
  • Install the required libraries
    $ curl -o boto-2.27.0.tar.gz -k
    $ pip install boto-2.27.0.tar.gz
    $ curl -o -k
    $ pip install
  • Configure boto
    $ touch /etc/boto.cfg
    $ vim /etc/boto.cfg

    Add the following lines to boto.cfg:

    aws_access_key_id = <your_access_key_here>
    aws_secret_access_key = <your_secret_key_here>

    Note: you can find a cheatsheet on how to use vim here.

  • Install the script to update your DNS. The script is also available on Github here.
    $ cd /share/MD0_DATA]
    $ mkdir scripts
    $ cd scripts        
    $ curl -o -k
  • Configure the script
    $ vim
    • Change the following lines (more info about Amazon Hosted Zones is available here):
      # Settings, Change me!
      HOSTED_ZONE = 'ZXQU10000001'
      DOMAIN_NAME = ''
    • Change the file permissions:
      $ chmod +x
    • Test the script:
      $ ./   
  • Run your update script every 5 minutes

    $ vim /etc/config/crontab
    • Add the following line:

      */5 * * * * /share/MD0_DATA/scripts/
    • Restart cron and reboot

      $ /etc/init.d/ restart
      $ reboot

Note: there seems to be a script available on the QNAP NAS just to retrieve your WAN ip, the script is located on your NAS under /etc/init.d/