Question

Customize TTL for a domain DNS SOA?

It seems that the DNS SOA TTL is fixed at 1800 seconds. This means that if I host the zone example.com at ns*.digitalocean.com, a negative result (NXDOMAIN) for mysubdomain.example.com will be cached for half an hour.

(This long-lived negative caching is a problem for my use case because the negative result gets cached by cert-manager before I can go in and add the correct A or CNAME record for my subdomain. If I create the DNS record first, it’s okay, but if I forget and create my Ingress first, then I’m stuck for half an hour!)

Would it be possible to set a custom TTL on the SOA record, via API? For example, I’d like to be able to do something simple like PATCH https://api.digitalocean.com/v2/domains/example.com with data {"ttl": 30}. Thank you for your assistance.


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

KFSys
Site Moderator
Site Moderator badge
January 20, 2022
Accepted Answer

Hi @compumike

Yes, the DigitalOcean API does allow you to change TTL on a DNS record, you can check there here:

https://docs.digitalocean.com/reference/api/api-reference/#operation/patch_update_domain_record

To update an existing record, send a PUT request to /v2/domains/$DOMAIN_NAME/records/$DOMAIN_RECORD_ID. Any attribute valid for the record type can be set to a new value for the record.

With curl it should look something like that:

curl -X PUT \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
  -d '{"ttl":"200"}' \
  "https://api.digitalocean.com/v2/domains/example.com/records/3352896"

Hope this helps.

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel