My ISP only provides me with a non-static IPv4 address. Getting a static one would cost hella extra and I really do not want to pay a dynamic DNS service monthly...
I automated the task by calling a URL that my FritzBox provides via MyFritz (to retrieve its current IP), and then update the DNS record in Hetzner. Cool if you want to deploy this to an off site server.
If your Router does not support such a feature, use the -l
(local) flag, to determine the IP address via your local network. The device running this obviously has to be in your local network for this to work.
- Clone the project to the system where you want to have this running (I have it on a Hetzner server).
- Rename
.template.env
to.env
and fill in the missing fields- DOMAIN: A URL that can be resolved to your router's current non-static IP. I was using a FritzBox, which provides the MyFritz service. When enabled the FritzBox then provides me with said URL. Learn more...
- HETZNER_API_TOKEN: Look at this guide to create a Hetzner DNS API token.
- DNS_RECORD_ID & DNS_RECORD_ZONE_ID: Acquired via the script itself by using the
-p
argument (API token needed).
- Create e.g. a cronjob, that looks something like this - updates once every hour (
dynDNS-cronjob.sh
also provided in this repository)
0 * * * * /path/to/dynDNS-cronjob.sh
- When given no argument, the script will try to resolve an IP from the given DOMAIN.
- The
-l
argument will retrieve the IP from the local network. - The
-p
argument will print your DNS record and record zone IDs.
Make sure you have python3
and the pipenv
package installed.
Clone the project to your local system with e.g.
git clone [email protected]:paul-eff/dynDNS.git
Navigate into the folder and execute the command
pipenv shell
Pipenv will now install all dependencies. From here on out you can change the code as you wish.
When finished, type exit
to leave the environment.
If you need this script e.g. in another language or something else, please leave me a message or issue :)!
Thanks to ipify for their lightningfast API!