Files
ducoterra f2015e2c71
All checks were successful
Podman DDNS Image / build-and-push-ddns (push) Successful in 1m3s
checkpoint commit
2026-05-05 06:26:40 -04:00

59 lines
1.9 KiB
Markdown

# Unifi
## Update DNS Records via API
```bash
export API_KEY=$(cat active/device_unifi/secrets/api-key)
# List site IDs
curl -L -g -k -s "https://192.168.1.1/proxy/network/integration/v1/sites" \
-H "Accept: application/json" \
-H "X-API-Key: ${API_KEY}" | jq -rc '.data[0].id'
# List domains
curl -L -g -k -s "https://192.168.1.1/proxy/network/integration/v1/sites/88f7af54-98f8-306a-a1c7-c9349722b1f6/dns/policies" \
-H "Accept: application/json" \
-H "X-API-Key: ${API_KEY}" | jq -r '.data[] | {domain, id}'
# List device domains
curl -L -g -k -s "https://10.1.0.1/proxy/network/v2/api/site/default/static-dns/devices" \
-H "Accept: application/json" \
-H "X-API-Key: ${API_KEY}" | jq -r
# List clients
curl -L -g -k -s "https://192.168.1.1/proxy/network/integration/v1/sites/88f7af54-98f8-306a-a1c7-c9349722b1f6/clients" \
-H "Accept: application/json" \
-H "X-API-Key: ${API_KEY}"
# List firewall policies
curl -L -g -k -s "https://192.168.1.1/proxy/network/integration/v1/sites/88f7af54-98f8-306a-a1c7-c9349722b1f6/firewall/policies" \
-H "Accept: application/json" \
-H "X-API-Key: ${API_KEY}"
# Create a record
curl -L -g -k -s "https://192.168.1.1/proxy/network/integration/v1/sites/88f7af54-98f8-306a-a1c7-c9349722b1f6/dns/policies" \
-H "Accept: application/json" \
-H "X-API-Key: ${API_KEY}" \
-H "Content-Type: application/json" \
-d "{
\"type\": \"A_RECORD\",
\"enabled\": true,
\"domain\": \"test.reeselink.com\",
\"ipv4Address\": \"10.1.0.100\",
\"ttlSeconds\": 300
}"
# Update a record
curl -L -g -k -s -X PUT "https://192.168.1.1/proxy/network/integration/v1/sites/88f7af54-98f8-306a-a1c7-c9349722b1f6/dns/policies/a5689d61-811a-48b0-a47c-2ece038e4356" \
-H "Accept: application/json" \
-H "X-API-Key: ${API_KEY}" \
-H "Content-Type: application/json" \
-d "{
\"type\": \"A_RECORD\",
\"enabled\": true,
\"domain\": \"test.reeselink.com\",
\"ipv4Address\": \"10.1.0.100\",
\"ttlSeconds\": 300
}"
```