This commit is contained in:
Talon 2022-03-07 20:49:07 -07:00
parent 5b0f2c7a67
commit 51de98f6a1
2 changed files with 17 additions and 6 deletions

View file

@ -2,27 +2,32 @@
Dynamic DNS for gandi.net
## How it works
* `curl` external IP from [icanhazip.com](https://icanhazip.com)
* `curl` to update the configured domain and record on [Gandi via the API](https://doc.livedns.gandi.net/)
* unless the IP has not changed (compared to previous check at
* Unless the IP has not changed (compared to previous check at
/tmp/DynGanDiNS.ip)
* Bash without the isms. Portability aimed.
* systemd timer included!
## How to use
Acquire an API key from Gandi by visiting your account page and finding the
authorized apps UI to generate one.
Clone this repo locally. Before `make install` update `Settings.env`. After installation the environment variables are sourced from `/etc/sysconfig/DynGanDiNS`.
authorized apps UI to generate one. Then clone this repo locally. Update `Settings.env` with your API key, domain and record name and then run `make install` (sudo as needed). After installation the environment variables are sourced from `/etc/sysconfig/DynGanDiNS` which will look like this (but hopefully with your info by now not empty variables):
```sh
GDDNS_API_KEY= # required API key from Gandi
GDDNS_API_KEY= # API key from Gandi
GDDNS_DOMAIN= # the domain name to update. example.com
GDDNS_RECORD_NAME= # the record to update. ex. raspi
# GDDNS_TTL="3600"
```
> If not using the systemd timer/service then you'll have to supply the environment variables some other way. Also probably don't bother with `make install` just use `DynGanDiNS.sh` how you please.
### Script
After `make install` the shell script is available in your path (from /bin) as `DynGanDiNS` and you can run that to make sure the environment is properly configured before enabling the timer and walking away.
### Timer
By default the timer is configured to run the service every hour. Use `systemctl edit DynGanDiNS.timer` to override `OnCalendar` as desired.
@ -33,6 +38,12 @@ systemctl enable --now DynGanDiNS.timer
```
> If you already ran the install then the settings are here: /etc/sysconfig/DynGanDiNS
## Why?
Internet service providers (ISPs) may or may not provide a static IP address for your connection to the World Wide Web. When they do not then it is _dynamic_ which poses a problem for domain name resolution (DNS) trying to associate the name with an IP that might change. To work around this some way of getting the current IP address and telling the DNS about it is required—ideally exactly and only when the IP changes.
This problem is very common for home computers wanting to expose services behind DNS to the larger network. For example a [Raspberry Pi](https://www.raspberrypi.org/) hosting an artisinal handcrafted website about knitting and gardening. Or maybe a [Wireguard VPN exposing an instance of Pi-hole for ad-block on the go!](https://docs.pi-hole.net/guides/vpn/wireguard/overview/). Or any other reason a server could be useful and you'd rather own instead of rent it.
## See Also
* [Gandi LiveDNS API](https://doc.livedns.gandi.net/)

View file

@ -1,4 +1,4 @@
GDDNS_API_KEY= # required API key from Gandi
GDDNS_API_KEY= # API key from Gandi
GDDNS_DOMAIN= # the domain name to update. ex. example.com
GDDNS_RECORD_NAME= # the record to update. ex. raspi
# GDDNS_TTL="3600"