How to find the magicDNS domain name from CLI?

when calling tailscale cert --cert-file domain.pem --key-file domain.key <domain> you need to be able to provide <domain>.

Is there a way to get <domain> via cli?

Also is it possible to get the Tailnet name from CLI for a node?

The Magic DNS sets up 100.100.100.100 as a DNS server that you can use to do a reverse lookup, so you can do something like this:

nslookup $(tailscale ip -1) | grep name | sed -e 's/.*name = [^.]*\.//' -e 's/.$//'

thanks for the inspiration. I got it down to the command

dig @100.100.100.100 +noall +answer +short -x  $(tailscale ip -1)

However that gives me the node FQDN where the domain is from the account. e.g. node-name.mailbox.gmail.com.beta.tailscale.net.
Which is a good result.

Now to work out how to do the same of the Tailnet name version?

What’s the tailnet name version?

They follow the pattern tail-scale.ts.net, e.g. cat-crocodile.ts.net

See Tailnet name · Tailscale.

So I experimented with it in the Tailscale Console. In the DNS tab, you can remove the (being deprecated) beta.tailscale.net name server:

You’ll see this message if you hover over the circled exclamation point there:

beta.tailscale.net is being sunsetted. If you are no longer using this nameserver, you can delete it.”

And then when you delete it, you’ll have to go through the “Are you Sure? This can’t be undone” prompt.

The upshot of all this is that the reverse lookup now returns your {tailnet-name}.ts.net hostname.

1 Like

Wow @kayvansylvan ! That worked a treat. Thanks. :sunglasses:

Awesome. Happy to help!