filiparag / hetzner_ddns

Hetzner Dynamic DNS (DDNS, DynDNS) daemon
BSD 2-Clause "Simplified" License
48 stars 7 forks source link

Error: No applicable records found #14

Closed Kartoffelpeter closed 1 month ago

Kartoffelpeter commented 1 month ago

Hi there, I've got a problem regarding getting my domain pointing to the correct IP-address.

Config

# Seconds between updates / TTL value
interval='7200'

# Hetzner DNS API key
key='lol'

# Top level domain name
domain='myawesome.domain'

# Space separated host subdomains (@ for domain itself)
records='bla blubb'

Output

hetzner-ddns_1  | [2024-07-20 09:17:42] Started Hetzner DDNS daemon
hetzner-ddns_1  | [2024-07-20 09:17:42] Reading configuration from /etc/hetzner_ddns.conf
hetzner-ddns_1  | [2024-07-20 09:17:43] Zone for myawesome.domain: some_key
hetzner-ddns_1  | [2024-07-20 09:17:43] Warning: Missing both A and AAAA records for bla.myawesome.domain
hetzner-ddns_1  | [2024-07-20 09:17:44] Warning: Missing both A and AAAA records for blubb.myawesome.domain
hetzner-ddns_1  | [2024-07-20 09:17:44] Error: No applicable records found myawesome.domain

I am using the docker image. Is there any obvious mistake? I already tried to create the A and AAAA records at the Hetzner DNS-Console. It didnt change anything.

filiparag commented 1 month ago

Can you manually run API call for getting all zones using your API key?

https://dns.hetzner.com/api-docs#operation/GetZones

Kartoffelpeter commented 1 month ago

Yes

$ read -s KEY
$ curl "https://dns.hetzner.com/api/v1/zones" -H "Auth-API-Token: $KEY"
{"zones":[{"id":"some-id","name":"myawesome.domain","ttl":7200,"registrar":"","legacy_dns_host":"","legacy_ns":["ns3.second-ns.de.","ns1.your-server.de.","ns.second-ns.com."],"ns":["ns3.second-ns.de.","ns1.your-server.de.","ns.second-ns.com."],"created":"2024-07-20 08:48:00.073 +0000 UTC","verified":"","modified":"2024-07-20 08:48:00.819 +0000 UTC","project":"","owner":"","permission":"","zone_type":{"id":"","name":"","description":"","prices":null},"status":"verified","paused":false,"is_secondary_dns":false,"txt_verification":{"name":"","token":""},"records_count":19}],"meta":{"pagination":{"page":1,"per_page":100,"previous_page":1,"next_page":1,"last_page":1,"total_entries":1}}}
filiparag commented 1 month ago

Im am not sure whether ns_.second-ns.de. are supported for this API. I am using _.ns.hetzner.de. and _.ns.hetzner.com..

Otherwise the output you provided seems proper.

Can you also try running these?

curl "https://dns.hetzner.com/api/v1/zones/some-id" \
    -H "Auth-API-Token: $KEY" \
    -H 'Content-Type: application/json; charset=utf-8'
curl "https://dns.hetzner.com/api/v1/records?zones_id=some-id" \
    -H "Auth-API-Token: $KEY" \
    -H 'Content-Type: application/json; charset=utf-8'
Kartoffelpeter commented 1 month ago
Click me ``` read -s ID $ curl "https://dns.hetzner.com/api/v1/zones/$ID" -H "Auth-API-Token: $KEY" -H 'Content-Type: application/json; charset=utf-8' { "zone": { "id": "$ID", "name": "myawesome.domain", "ttl": 7200, "registrar": "", "legacy_dns_host": "", "legacy_ns": [ "ns3.second-ns.de.", "ns1.your-server.de.", "ns.second-ns.com." ], "ns": [ "ns3.second-ns.de.", "ns1.your-server.de.", "ns.second-ns.com." ], "created": "2024-07-20 08:48:00.073 +0000 UTC", "verified": "", "modified": "2024-07-20 08:48:00.819 +0000 UTC", "project": "", "owner": "", "permission": "", "zone_type": { "id": "", "name": "", "description": "", "prices": null }, "status": "verified", "paused": false, "is_secondary_dns": false, "txt_verification": { "name": "", "token": "" }, "records_count": 19 } } $ curl "https://dns.hetzner.com/api/v1/records?zones_id=$ID" -H "Auth-API-Token: $KEY" -H 'Content-Type: application/json; charset=utf-8' { "records": [ { "id": "", "type": "SOA", "name": "@", "value": "ns1.your-server.de. postmaster.your-server.de. 2024072009 86400 10800 3600000 3600", "zone_id": "$ID", "created": "2024-07-20 08:48:00.421 +0000 UTC", "modified": "2024-07-20 09:17:38.906 +0000 UTC" }, { "id": "5519117bc539ac05251d597dfa32bc04", "type": "NS", "name": "@", "value": "ns1.your-server.de.", "zone_id": "$ID", "created": "2024-07-20 08:48:01.042 +0000 UTC", "modified": "2024-07-20 08:48:01.042 +0000 UTC" }, { "id": "4c644972b390e76874524694a7994e72", "type": "NS", "name": "@", "value": "ns.second-ns.com.", "zone_id": "$ID", "created": "2024-07-20 08:48:01.052 +0000 UTC", "modified": "2024-07-20 08:48:01.052 +0000 UTC" }, { "id": "", "type": "NS", "name": "@", "value": "ns3.second-ns.de.", "zone_id": "$ID", "created": "2024-07-20 08:48:01.063 +0000 UTC", "modified": "2024-07-20 08:48:01.063 +0000 UTC" }, { "id": "", "type": "A", "name": "@", "value": "", "zone_id": "$ID", "created": "2024-07-20 08:48:01.073 +0000 UTC", "modified": "2024-07-20 08:56:10.742 +0000 UTC" }, { "id": "", "type": "A", "name": "www", "value": "", "zone_id": "$ID", "created": "2024-07-20 08:48:01.082 +0000 UTC", "modified": "2024-07-20 08:56:07.166 +0000 UTC" }, { "id": "", "type": "AAAA", "name": "@", "value": "", "zone_id": "$ID", "created": "2024-07-20 08:48:01.091 +0000 UTC", "modified": "2024-07-20 08:48:01.091 +0000 UTC" }, { "id": "", "type": "AAAA", "name": "www", "value": "", "zone_id": "$ID", "created": "2024-07-20 08:48:01.099 +0000 UTC", "modified": "2024-07-20 08:48:01.099 +0000 UTC" }, { "id": "", "type": "MX", "name": "@", "value": "10 www4.your-server.de.", "zone_id": "$ID", "created": "2024-07-20 08:48:01.107 +0000 UTC", "modified": "2024-07-20 08:48:01.107 +0000 UTC" }, { "id": "", "type": "TXT", "name": "@", "value": "\"v=spf1 +a +mx ?all\"", "zone_id": "$ID", "created": "2024-07-20 08:48:01.114 +0000 UTC", "modified": "2024-07-20 08:48:01.114 +0000 UTC" }, { "id": "", "type": "CNAME", "name": "autoconfig", "value": "mail.your-server.de.", "zone_id": "$ID", "created": "2024-07-20 08:48:01.124 +0000 UTC", "modified": "2024-07-20 08:48:01.124 +0000 UTC" }, { "id": "", "type": "SRV", "name": "_autodiscover._tcp", "value": "0 100 443 mail.your-server.de.", "zone_id": "$ID", "created": "2024-07-20 08:48:01.135 +0000 UTC", "modified": "2024-07-20 08:48:01.135 +0000 UTC" }, { "id": "", "type": "SRV", "name": "_pop3s._tcp", "value": "0 100 995 mail.your-server.de.", "zone_id": "$ID", "created": "2024-07-20 08:48:01.145 +0000 UTC", "modified": "2024-07-20 08:48:01.145 +0000 UTC" }, { "id": "", "type": "SRV", "name": "_imaps._tcp", "value": "0 100 993 mail.your-server.de.", "zone_id": "$ID", "created": "2024-07-20 08:48:01.155 +0000 UTC", "modified": "2024-07-20 08:48:01.155 +0000 UTC" }, { "id": "", "type": "SRV", "name": "_submission._tcp", "value": "0 100 587 mail.your-server.de.", "zone_id": "$ID", "created": "2024-07-20 08:48:01.163 +0000 UTC", "modified": "2024-07-20 08:48:01.163 +0000 UTC" }, { "id": "", "type": "A", "name": "bla.myawesome.domain", "value": "", "zone_id": "$ID", "created": "2024-07-20 09:16:41.925 +0000 UTC", "modified": "2024-07-20 09:16:41.925 +0000 UTC" }, { "id": "", "type": "A", "name": "blubb.myawesome.domain", "value": "", "zone_id": "$ID", "created": "2024-07-20 09:17:10.298 +0000 UTC", "modified": "2024-07-20 09:17:10.298 +0000 UTC" }, { "id": "", "type": "AAAA", "name": "bla.myawesome.domain", "value": "", "zone_id": "$ID", "created": "2024-07-20 09:17:27.123 +0000 UTC", "modified": "2024-07-20 09:17:27.123 +0000 UTC" }, { "id": "", "type": "AAAA", "name": "blubb.myawesome.domain", "value": "", "zone_id": "$ID", "created": "2024-07-20 09:17:38.761 +0000 UTC", "modified": "2024-07-20 09:17:38.761 +0000 UTC" } ] } ```
filiparag commented 1 month ago

Are you running those commands on the host or inside the container? Maybe its networking configuration is broken. Otherwise all of the outputs seem fine.

Kartoffelpeter commented 1 month ago

I ran those commands on the host machine. But they also work inside the container:

$ cat docker-compose.yml
version: '3'

services:
  hetzner-ddns:
    image: filiparag/hetzner_ddns
    restart: unless-stopped
    volumes:
      - ./hetzner_ddns.conf:/etc/hetzner_ddns.conf:ro
$ dc exec hetzner-ddns sh
/ # cat /etc/hetzner_ddns.conf
# Seconds between updates / TTL value
interval='7200'

# Hetzner DNS API key
key='lol'

# Top level domain name
domain='myawesome.domain'

# Space separated host subdomains (@ for domain itself)
records='bla blubb'
/ # read -s KEY
/ # curl "https://dns.hetzner.com/api/v1/zones" -H "Auth-API-Token: $KEY"
-> Same output as last time
/ # read -s ID
/ # curl "https://dns.hetzner.com/api/v1/zones/$ID" -H "Auth-API-Token: $KEY" -H 'Content-Type: application/json; charset=utf-8'
-> Same output as last time
/ # curl "https://dns.hetzner.com/api/v1/records?zones_id=$ID" -H "Auth-API-Token: $KEY" -H 'Content-Type: application/json; charset=utf-8'
-> Same output as last time
filiparag commented 1 month ago

Thanks for providing the log.

The only way I am able to reproduce your initial output is to intentionally put bad values into records variable in the configuration file:

image

Are you able to run this utility in any other way (e.g. systemd service)?

Kartoffelpeter commented 1 month ago

I think it doesn't hurt to share the real records. It's

records='paperless cloud'

It is possible to not use docker, but it would to great to use docker.

filiparag commented 1 month ago

I set my configuration file to include only your records and have added them to DNS Console. It works when I start the container afterwards:

image

filiparag commented 1 month ago

It is possible to not use docker, but it would to great to use docker.

Can you try running it differently, at least as a test?

Kartoffelpeter commented 1 month ago

I tried the deb-package (https://github.com/filiparag/hetzner_ddns/releases/download/0.2.4/hetzner_ddns-0.2.4.deb) with the same result.

$ cat /etc/hetzner_ddns.conf
    interval='60'                           # Seconds between updates / TTL value
    key='lol'                               # Hetzner DNS API key
    domain='myawesome.domain'               # Top level domain name
    records='cloud paperless'               # Space separated host subdomains (@ for domain itself)
$ sudo hetzner_ddns
    [2024-08-01 07:47:36] Started Hetzner DDNS daemon
    [2024-08-01 07:47:36] Reading configuration from /etc/hetzner_ddns.conf
    [2024-08-01 07:47:36] Zone for myawesome.domain: something
    [2024-08-01 07:47:37] Warning: Missing both A and AAAA records for cloud.myawesome.domain
    [2024-08-01 07:47:37] Warning: Missing both A and AAAA records for paperless.myawesome.domain
    [2024-08-01 07:47:37] Error: No applicable records found myawesome.domain
filiparag commented 1 month ago

I think I found the problem. When you call the API you get FQDN responses:

{
      "id": "<something>",
      "type": "AAAA",
      "name": "blubb.myawesome.domain",
      "value": "<some ipv6>",
      "zone_id": "$ID",
      "created": "2024-07-20 09:17:38.761 +0000 UTC",
      "modified": "2024-07-20 09:17:38.761 +0000 UTC"
}

while I get

{
      "id": "<something>",
      "type": "AAAA",
      "name": "blubb",
      "value": "<some ipv6>",
      "ttl": 60,
      "zone_id": "$ID",
      "created": "2024-03-11 23:46:35.492 +0000 UTC",
      "modified": "2024-03-11 23:46:40.459 +0000 UTC"
}

I am not sure why that is 🤷🏻‍♂️...

It should be solvable with a minor problem - if you have blubb.myawesome.domain.myawesome.domain. subdomain, it will mix them up. I think it's not very likely to happen.

filiparag commented 1 month ago

@Kartoffelpeter Can you test updated version?

Just replace /usr/bin/hetzner_ddns executable or run it with sudo ./hetzner_ddns.sh

Kartoffelpeter commented 1 month ago

This looks good

$ chmod +x hetzner_ddns.sh
$ sudo ./hetzner_ddns.sh
    [2024-08-05 10:54:37] Started Hetzner DDNS daemon
    [2024-08-05 10:54:37] Reading configuration from /usr/local/etc/hetzner_ddns.conf
    [2024-08-05 10:54:38] Zone for myawesome.domain: <zone_id>
    [2024-08-05 10:54:38] IPv4 record for cloud.myawesome.domain: <some_hash>
    [2024-08-05 10:54:38] IPv6 record for cloud.myawesome.domain: <some_hash>
    [2024-08-05 10:54:39] IPv4 record for paperless.myawesome.domain: <some_hash>
    [2024-08-05 10:54:39] IPv6 record for paperless.myawesome.domain: <some_hash>
    [2024-08-05 10:54:39] Configuration successful
    [2024-08-05 10:54:39] Watching for IP address and record changes
filiparag commented 1 month ago

Good to hear that.

Can you manually edit the those records in DNS console to something random to test whether IP changing also works properly?

Kartoffelpeter commented 1 month ago

I tested it and it worked properly. I would love to see this update in the docker image ;)

filiparag commented 1 month ago

I will release the update in a bit, just wanted to make sure it works first.