Home Assistant Community Add-on: GandiDns

Hello !
I’ve just released a new add-on for Home Assistant.
It’s GandiDns. It will keep synchronized your DNS zone for your domain name with your public IP.
This is usefull if your isp provider is changing your IP times to times.

For this you needs a Gandi Account and your domain name needs to be managed by Gandi.net of course.

You can add this repository to your ho assistant Add-Ons store https://github.com/benlbrm/home-assistant-addons

Hope it will help.
Benlbrm

2 Likes

thanks for this. Im struggling adding more than one item. It works great if i just have one.

My config

api_key: secret
domain: domain.com
reccords:
  - www.domain.com
  - '@'
  - test.domain.com

and my logs

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] scripts: applying... 
[fix-attrs.d] scripts: exited 0.
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 00-banner.sh: executing... 
-----------------------------------------------------------
 Add-on: GandiDNS
 Update Gandi dns zone
-----------------------------------------------------------
 Add-on version: 0.0.1
 There is an update available for this add-on!
 Latest add-on version: null
 Please consider upgrading as soon as possible.
parse error: Expected string key before ':' at line 1, column 4
[16:34:52] ERROR: Unknown HTTP error occured
 System:   (amd64 / qemux86-64)
 Home Assistant Core: 2020.12.2
 Home Assistant Supervisor: 2020.12.7
-----------------------------------------------------------
 Please, share the above information when looking for help
 or support in, e.g., GitHub, forums or the Discord chat.
-----------------------------------------------------------
[cont-init.d] 00-banner.sh: exited 0.
[cont-init.d] 01-log-level.sh: executing... 
[cont-init.d] 01-log-level.sh: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
[16:34:53] INFO: Starting Ip Updater...
[16:34:53] INFO: Updater Started

also not sure if reccords should be records

Hello,
in records you should have [www, @, test] not the full domain name.
But care, I’ve saw than when updating @ reccord on gandi, that destroy MX reccords of my domain, I have to check that but I have no time actually

Thanks

Ive gone with

api_key: secret
domain: domain.com
reccords:
  - www
  - '@'
  - xxx
  - yyy

Seems to be some issues with the @ as you say. Will keep an eye out. My IP very rarely changes .

Hi,
I got a look to gandi api documentation, and it’s seams logic than when you are updating @ record, it removes MX entries.
https://api.gandi.net/docs/livedns/#v5-livedns-domains-fqdn-records-rrset_name

The put method I’ve used replace all record entries, by the one I provide.
So please be careful updating @ record.
Benoît

Hi @benlbrm and thanks for this add-on !
Before I had the opportunity of seeing your add-on, I’ve setup a Rest command pointed to the https://api.gandi.net/v5/livedns/domains/{fqdn}/records/{rrset_name}/{rrset_type} endpoint. This is working great and thanks to the “rrset_type” URL parameter, it doesn’t destroy MX records !
For those interested, here’s the full configuration.yaml excerpt:

rest_command:
  update_gandi:
    url: https://api.gandi.net/v5/livedns/domains/mydoma.in/records/%40/A
    method: put
    content_type: application/json
    headers:
      authorization: Apikey myApiKey
    payload: '{"rrset_values":["{{ state_attr("binary_sensor.wan_status", "wan_ipaddress") }}"],"rrset_ttl":300}'

Where %40 is the URL-encoded “@” for root record (and could be replaced by a subdomain, of course), mydoma.in is the FQDN of the DNS zone being updated, myApiKey is the Gandi v5 API key to use. And finally, I’m using a template to retrieve the new WAN IP from an attribute of a WAN sensor (which, incidentally, has an automation triggering this very Rest Command on state change).

In any case, the important bit is that if you use this endpoint URL (with the /A at the end as the “rrset_type”), your MX records should stay untouched.

Hope this helps.

Cheers !

2 Likes

Hey @lesensei I will adapt the add-on with when I will have some free time :wink:

Thanks !

1 Like