Created
July 25, 2024 19:25
-
-
Save varenc/971796720a31c3b16e6c99903794bc1e to your computer and use it in GitHub Desktop.
Tailscale on macOS DNS resolver workaround to https://github.com/tailscale/tailscale/issues/12244
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Workaround for https://github.com/tailscale/tailscale/issues/12244 on macOS | |
### Usage | |
# Just put this in a shell RC file (~/.zshrc) and run `tailscaleDNSHack` | |
# With no params it sets the tailscale DNS to what your `NET_SERVICE`'s DNS is. | |
# Or pass in an argument to set that as the DNS | |
function tailscaleDNSHack () { | |
local NET_SERVICE="Wi-Fi" | |
if [ -z $1 ] | |
then | |
local NEW_DNS="$(networksetup -getdnsservers "$NET_SERVICE")" | |
echo "No DNS passed in, using primary interface default: $NEW_DNS" | |
else | |
local NEW_DNS="$1" | |
fi | |
local TS_UUID="$(scutil --nc list | awk '/io.tailscale.ipn.macos/ {print $3}')" | |
echo "Setting DNS for Tailscale service UUID '$TS_UUID' to '$NEW_DNS'" | |
sudo scutil <<EOF | |
open | |
d.init | |
d.add ServerAddresses * $NEW_DNS | |
set State:/Network/Service/$TS_UUID/DNS | |
quit | |
EOF | |
echo "Done setting DNS for Tailscale service UUID '$TS_UUID' to '$NEW_DNS'! Here's the result:" | |
echo "show State:/Network/Service/${TS_UUID}/DNS" | scutil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To clear this easily I've been using this script: