This is about the script originally written for https://github.com/ryuheechul/dotfiles/commit/1c5795d4e69ad7ad8c191e3e96fe43155522739a#diff-4f848b5499b37dbeb494a252ab49d56831abb5b12dbd362ab5182f509f7ad97b
the script is pretty short and relatively simple, so I recommend you to read it but the gist is below
- get necessary details regarding (your already configured) zerotier network interface and running DNS server
- configure DNS routing via
resolvectl
forsystemd-resolved
with the parse information from the previous step - (now resolving to FQDN (e.g.
host device.home.arpa
) should work as well as search domain (e.g.host device
) - (unfortunately the change doesn't last after a reboot - so I'm looking into a way to resolve this)
- zerotier DNS client setup seems to be brittle so on Linux
- and the solution that I came up with is not that complicated to implement (at least in a rudimentary way)
- why not Tailscale Magic DNS experience for Zerotier (on Linux) as well!
- that you already have setup zerotier network on your linux machine
- test via
sudo zerotier-cli info
andsudo zerotier-cli listnetworks
- if you are using NixOS see this as an example
- test via
- that you are running zeronsd on one of your zerotier networked node
- you can get some idea on how to do that at https://github.com/zerotier/zeronsd/blob/main/docs/quickstart.md
- although this include some other information (like client configuration) too
- (and this will also not only run the DNS exposed on 53 port but also advertizes or tells that to zerotier central as well)
- you would need to not block 53 from outside (via firewall) though in order for other machines to reach that port
- if you are using NixOS see this as an example
- you can get some idea on how to do that at https://github.com/zerotier/zeronsd/blob/main/docs/quickstart.md
- that you are using
systemd-resolved
because this script depends on it- (and maybe you would want it)
- test via
resolvectl status
- if you are not using
systemd-resolved
there seem to be another option- (although I have no experience with it)
- that you have jq installed
- now you can run it ans enjoy the "Magic DNS" experience (assuming it worked)!
^ that didn't work as I hoped as the global setting is different from individual interface.
And now I automated via systemd service and here is the code. Which basically generates and installs a systemd service unit like below.
Although the service file above generated for NixOS, it's a simple service that you can easily mimic on your non-nix system.
/nix/store/9cqg....dns-resolved-start/bin/zerotier-dns-resolved-start
's content is same as this one.