actually use it

main
Talon 11 months ago
parent 51de98f6a1
commit e3aa417b52
  1. 2
      DynGanDiNS.service
  2. 4
      DynGanDiNS.sh
  3. 2
      DynGanDiNS.timer
  4. 21
      README.md
  5. 7
      Settings.env

@ -3,4 +3,4 @@ Description=Dynamic DNS for Gandi
[Service]
EnvironmentFile=/etc/sysconfig/DynGanDiNS
ExecStart=/bin/DynGanDiNS.sh
ExecStart=/bin/DynGanDiNS

@ -52,7 +52,7 @@ if ! curl --fail --silent \
--header "X-Api-Key:$GDDNS_API_KEY" \
--data "$request_data" \
https://dns.api.gandi.net/api/v5/domains/"$GDDNS_DOMAIN"/records/"$GDDNS_RECORD_NAME"/A; then
printf "error: failed to update %s to point to %s\n" "$GDDNS_RECORD_NAME.$GDDNS_DOMAIN" "$ip"
printf "error: failed to update %s to point to %s\n" "$GDDNS_RECORD_NAME for $GDDNS_DOMAIN" "$ip"
exit 1
fi
printf "success: %s now points to %s\n" "$GDDNS_RECORD_NAME.$GDDNS_DOMAIN" "$ip"
printf "success: %s now points to %s\n" "$GDDNS_RECORD_NAME for $GDDNS_DOMAIN" "$ip"

@ -2,7 +2,7 @@
Description=Run DynGanDiNS regularly
[Timer]
OnCalendar=* *-*-* */1:00:00
OnCalendar=00/1:00
[Install]
WantedBy=timers.target

@ -14,19 +14,15 @@ Dynamic DNS for gandi.net
## How to use
Acquire an API key from Gandi by visiting your account page and finding the
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):
authorized apps UI to generate one. Then clone this repo locally. Update `Settings.env` with your API key, domain and record name. 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= # 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"
GDDNS_API_KEY=
GDDNS_DOMAIN=
GDDNS_RECORD_NAME=
```
> 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.
> GDDNS_TTL is an optional setting that defaults to 3600
### Timer
@ -38,11 +34,16 @@ systemctl enable --now DynGanDiNS.timer
```
> If you already ran the install then the settings are here: /etc/sysconfig/DynGanDiNS
If this is the first time setting everything up you may want to run the service right away instead of waiting for the timer. Ensure it worked by checking `journalctl -u DynGanDiNS`.
```sh
systemctl start 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.
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

@ -1,4 +1,3 @@
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"
GDDNS_API_KEY=
GDDNS_DOMAIN=
GDDNS_RECORD_NAME=

Loading…
Cancel
Save