# Ionos DNS updates A simple script used to send dynamic DNS updates to the Ionos API. Using this script requires you to have your domain registered with Ionos, and having obtained an [API key from them](https://developer.hosting.ionos.com/docs/getstarted). Any subdomains you add to `config.yml` are added automatically to your Ionos account and pointed at your public IP (provided that your API Key is valid and you own the respective parent domain). **NOTE:** Removing the domains from `config.yml` does not remove their global DNS record. They will still be publically registered subdomains and point to whatever public IP you had when you last ran the script with the respective domain listed inside `config.yml`. You must log in to your Ionos account and remove them manually to de-register the domain. ### Dependencies Python 3.6 or above. Required python libraries: - [requests](https://pypi.org/project/requests/) - [pyyaml](https://pypi.org/project/PyYAML/) ### Configuration Configuration of your DNS updates is declared inside the file `config.yml`. Once modified, this file **must be kept secret**. If your API key or your DNS update URL leaks to a bad actor, anyone visiting your domains runs the risk of being DNS-poisoned. First, you will need to write your Ionos API keypair into the config file. Paste the respective values of your Ionos API-keypair into the config as follows: ```yaml apikey: prefix: secret: ``` Next, add every domain you wish to send an update for to the `domains` list. The script will set a global DNS record for each listed domain and have it point to the local host's public IP address. The `domains` list should have the following format: ```yaml domains: - example.com - subdomain1.example.com - subdomain2.example.com ``` You may optionally set a descriptive string which is sent along with the update: ```yaml description: "Dynamic DNS update." ``` As of right now, I am actually not sure what the description is needed for, but the API requires it to be present in the request. The value displayed here is used by default if you don't override it in `config.yml`. ### Regular DNS updates In order to keep your DNS records synchronized with your public IP address, you should run the update script periodically. As of this writing, Ionos limit dynamic DNS updates via API to 2 requests per minute, so don't send requests more frequently than that. In order to update your DNS IPs once every minute, call the script once a minute. (Duh!) You can set your crontab to the following to achieve this: ``` */1 * * * * /path/to/dnsupdate.py ``` Just make sure that the script is executable by the user whose cronjob is executing it, and that `config.yml` is listed in the same directory as the script itself. Run it manually at least once to make sure that everything is working. If the script runs without throwing an exception, everything worked and your DNS records now point to your public IP.