Skip to content

Commit

Permalink
Clarify UniFi OS config instructions and add manual update commands
Browse files Browse the repository at this point in the history
This is based on @philsward helpful feedback in #42.
  • Loading branch information
m-d-brown authored and willswire committed Feb 18, 2024
1 parent f9f695a commit 62e8dbb
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ You must have a Cloudflare account and your domain must be configured to point t
#### Install With Click To Deploy
1. Deploy the Worker: [![Deploy to Cloudflare Workers](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/workerforce/unifi-ddns)
3. Navigate to the Cloudflare Workers dashboard
4. Once the deployment is complete, take note of it's \*.workers.dev route. More on routes for Cloudflare Workers [here](https://developers.cloudflare.com/workers/platform/routes#routes-with-workersdev).
4. Once the deployment is complete, take note of it's `\*.workers.dev` route. More on routes for Cloudflare Workers [here](https://developers.cloudflare.com/workers/platform/routes#routes-with-workersdev).
5. Create an API token so the Worker can update your DNS records. Go to https://dash.cloudflare.com/profile/api-tokens and select "Create token". On the next page, scroll down and click the "Get Started" button next to the "Create Custom Token" label. Select **Zone:DNS:Edit** for the "Permissions" drop-down, and include your target zone under the "Zone Resources" drop-down. Copy your API Key - you will need it later when configuring your UniFi OS Controller.

#### Install With Wrangler CLI
1. Clone or download this project
2. Ensure you have the [Wrangler CLI](https://developers.cloudflare.com/workers/wrangler/install-and-update/) installed on your system
3. Log in with wrangler, and run `wrangler deploy`.
4. Once you have created the worker, take note of it's \*.workers.dev route. More on routes for Cloudflare Workers [here](https://developers.cloudflare.com/workers/platform/routes#routes-with-workersdev).
4. Once you have created the worker, take note of it's `\*.workers.dev` route. More on routes for Cloudflare Workers [here](https://developers.cloudflare.com/workers/platform/routes#routes-with-workersdev).
5. Create an API token so the Worker can update your DNS records. Go to https://dash.cloudflare.com/profile/api-tokens and select "Create token". On the next page, scroll down and click the "Get Started" button next to the "Create Custom Token" label. Select **Zone:DNS:Edit** for the "Permissions" drop-down, and include your target zone under the "Zone Resources" drop-down. Copy your API Key - you will need it later when configuring your UniFi OS Controller.

### Configuring UniFi OS
Expand All @@ -30,10 +30,22 @@ You must have a Cloudflare account and your domain must be configured to point t
- `Hostname`: the full subdomain and hostname of the record you want to update (e.g. `subdomain.mydomain.com`, `mydomain.com` for root domain)
- `Username`: the domain name containing the record (e.g. `mydomain.com`)
- `Password`: the Cloudflare API Token you created earlier
- `Server`: the Cloudflare Worker route `<worker-name>.<worker-subdomain>.workers.dev/update?ip=%i&hostname=%h`.
- `Server`: the Cloudflare Worker route `<worker-name>.<worker-subdomain>.workers.dev/update?ip=%i&hostname=%h`
- On UniFi devices older than the UDM the `Server` value should be configured with no URL path: `<worker-name>.<worker-subdomain>.workers.dev`.
- Many UniFi devices do not handle the `https://` prefix in the URL for the `Server`
value. You should remove it, using `<worker-name>.<worker-subdomain>.workers.dev`
instead of `https://<worker-name>.<worker-subdomain>.workers.dev`.

To test the configuration and force an update:

1. Ssh into your UniFi device
2. Run `ps aux | grep inadyn`
3. Note the configuration file path referenced by the running inadyn process e.g.
`/run/ddns-eth4-inadyn.conf`.
4. Run `inadyn -n -1 --force -f <config-path>` e.g. `inadyn -n -1 --force -f /run/ddns-eth4-inadyn.conf`

Also check `/var/log/messages` for error messages related to `inadyn`.

#### Important Notes!
- If you are attempting to update a subdomain (`sub.example.com`), you must manually create an A record for it **first** in your Cloudflare dashboard.
- On UniFi devices older than the UDM, the `Server` value should be configured as seen below, with no path suffix: `<worker-name>.<worker-subdomain>.workers.dev`
- If you receive a log message on your Unifi device like `inadyn[2173778]: Failed resolving hostname https: Name or service not known`, remove `https://` from the `Server` field.

- If you receive a log message on your Unifi device like `inadyn[2173778]: Failed resolving hostname https: Name or service not known`, remove `https://` from the `Server` field as described the Configuring section.

0 comments on commit 62e8dbb

Please sign in to comment.