Skip to content

A simple tool to easily update a DNS record hosted by the registrar Gandi.net with your public IP

License

Notifications You must be signed in to change notification settings

seb-pereira/synogandip

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

synogandip Build Status

A simple tool to easily update a DNS record hosted by the registrar Gandi.net with your public IP


If you answer yes to these questions you might be interested by this tool:

  1. Is your domain registered on gandi.net?

  2. Does your public IP address assigned by your internet provider change over time (i.e., a dynamic IP)?

  3. Do you host services you want available over Internet using your domain name?

If you own a Synology NAS here is an additional reason: the tool can be easily scheduled on your NAS without requiring additional dependency* such as Python, Docker or any other package (tested with DSM 7). This use case is addressed in section "Configuring on your Synology NAS".

Getting started

This tools is composed of two files: a configuration file (synogandip.conf) and a bash script (synogandip.sh). The script requires curl and jq.

  1. Download and unzip: https://github.com/seb-pereira/synogandip/releases

  2. Edit the configuration file synogandip.conf

  • gandi.api.key => your gandi.net API key
  • domain.name => your domain name. Example: example.org
  • domain.record => set the name of the sub-domain record to update. Example: to update record for mysite.example.org, set domain.record=mysite
  1. Run
usage: synogandip.sh [options]
  -f | --file <path>  path to a configuration file. Default: synogandip.conf located in same folder.
  -v                  enable verbose mode: displays remote call responses and additional information.
  -d                  enable dry run mode: record is not created or updated. This option force the verbose mode.
  --version           display the version.

How it works?

The tool calls gandi.net APIs to manage the DNS record of the sub-domain you want to reference your public IP. That is why you must set the configuration property gandi.api.key to your gandi.net API key.

  • Step 1 - determines your public IP address

    • By default it relies on https://ifconfig.me.
    • You can set the configuration property public.ip.resolver to use another service.
  • Step 2 - retrieves your sub-domain record

    • The DNS record is identified using the configuration properties domain.name and domain.record. For example, if you want mysite.example.org to reference to your public IP, you set domain.name=example.org and domain.record=mysite.
  • Step 3 - this last step depends on the situation:

    • If the record does not exist, the tool creates a A record with your public IP and a default TTL to 1800. You can set the configuration property domain.ttl to customize the TTL to use when the record is created.
    • If the record exist but it does not reference your current IP: the tool updates the record with the current IP.

Configuring on your Synology NAS

You use the DSM Scheduler to run synogandip.sh regularely so your DNS record matches your public IP address. You must copy synogandip.sh and its configuration file on your NAS, and then you create a Scheduler task. I choosed a non-admin user account to run the Schedule task.

1. Install files

With File Station,

  • create a new folder in the user home. Example: /homes/<user>/ddns
  • copy both files in it

The configuration file contains an API key which is a sensitive information that must be protected from unauthorized access. Only administrators and the dedicated user should have read access to the configuration file. Update /homes/<user>/ddns folder properties:

  • 1/ select the Permissions tab
  • 2/ check Apply to this folder, sub-folders and files
  • 3/ select Advanced options and select Exclude inherited permissions
  • 4/ allow Administrators: select Create:
    • user or group: administrator
    • Permission: check Administration
    • click Done and select yes to the information message.
  • 5/ allow read access to <user>: select Create:
    • user or group: select the home user
    • Permission: check Read
    • click Done.
  • 6/ select the General tab and copy the Location, you will need it in later (should be similar to /volume1/homes/<user>/ddns)

2. Create a scheduler task

In Control Panel, select the Task Scheduler

  • create a new task: select Create > Scheduled Task > User-defined script
  • General tab
    • Name your task. Example DDNS mysite.example.org
    • Select the user who owns the home folder
  • Schedule tab
    • choose when you want to run the script. It depends on the frequency your IP address is likely to change.
  • Task settings tab
    • Notification: I recommend to activate the option Send run details by email so you have a report, and you can identified when the IP actually changes.
    • Run command: set the user defined script to bash <location>/synogandip.sh, where you replace <location> (see step 1 point 6)
  • select Ok to create the task.

3. Test

You can temporarely activate Task Scheduler > Settings: save output results to get a report written in a file when the task ends.

Run your task and check the result. If you enabled the email notification you should also receive an email.

Once you are satified you may enable the scheduling and disable the save output result setting to prevent report files to accumulate over time.

Known limitations

  • AAAA record update (IPv6) is not supported

Developed with ❤️ on 🌍

About

A simple tool to easily update a DNS record hosted by the registrar Gandi.net with your public IP

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages