Toggle Mac client DNS settings programmatically?

I use Tailscale with NextDNS. While this is an awesome combination, it’s quite easy to be overly aggressive in my NextDNS configuration which can cause legitimate websites to break. It’s tedious to diagnose each such case via the NextDNS portal, so instead I do a quick test by disabling Tailscale DNS settings and then refreshing the page. I’d like to optimize this process if I can, because it’s just too many clicks to enable/disable DNS settings via GUI menus.

Is there anyway to control this setting programmatically (which I can then in turn wrap into an Alfred workflow)? I’ve tried to handle this with an applescript; however graphical GUI automation is quite flaky. I’ve poked at the CLI, but I do not see the DNS settings exposed there.

Is there another way? If not, how can I go about putting in a feature request?

I took a different direction to solve this challenge.

I am using the Tailscale API to update my DNS servers. I used a python script tied to Alfred so I can swap between Cloudflare’s DNS and the IPv6 address associated with my NextDNS profile.

When viewing the NextDNS setup page and toggling state with Alfred, the page immediately updates showing if I am resolving via NextDNS.

I’m not sure how I missed this before, but this is easily addressed with the tailscale cli.

running the cli with “up --accept-dns=false” unchecks the DNS option. This works even if the tunnel is already up. Conversely, setting it to true re-enables it.