-
Copy
wrangler_example.toml
aswrangler.toml
, and set:ZONE_ID
: You can find it in your domain homepage.EMAIL
: Your Cloudflare account email.KEY
: Your Cloudflare API key, generate it here and allow it modify dns record.TOKEN_ddns.example.com
: The key format is"TOKEN_" + your_sub_domain
. The value is the token for your sub-domain, you can set it as a long random string.
-
Run
npx wrangler deploy
. -
You can
curl -X POST https://ddns.YOUR_WORKER_DOMAIN.workers.dev/update/ddns.example.com/EXAMPLE_TOKEN
to update the record to the client ip address. If you want to update different subdomains, you may add multiple key-values likeTOKEN_ddns2.example.com
.
You can also set COUNTRY
variable in wrangler.toml
to only allow requests from that country(for example, when you misused a VPN, the DNS record will be your VPN outbound IP, which maybe not what you want). If you don't want it, just leave the key blank. Country code format is as ISO 3166-1 Alpha 2
, for example, CN
, US
, SG
.
The doc helps you prepare the environment.
Wow so wasm!