Last active
December 9, 2025 16:49
-
-
Save luckman212/356dfc72396b838a055ec10d315b042b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| #!/bin/zsh --no-rcs | |
| # https://github.com/tailscale/tailscale/issues/18101 | |
| # https://gist.github.com/luckman212/356dfc72396b838a055ec10d315b042b | |
| zmodload zsh/datetime | |
| #get a random peer | |
| ts_json=$(tailscale status --json) | |
| all_peers=$(jq '.Peer | to_entries | map(select(.value.DNSName!="")) | map(.value.DNSName)' <<< "$ts_json") | |
| num_peers=$(jq 'length' <<< "$all_peers") | |
| ts_domain=$(jq -r '.MagicDNSSuffix' <<< "$ts_json") | |
| peer=$(jq -r --argjson i $(( RANDOM % num_peers )) '.[$i] | sub("\\.$";"")' <<< "$all_peers") | |
| [[ -n $peer ]] && [[ -n $ts_domain ]] || exit 1 | |
| # install quad100 resolver stub | |
| stub="/etc/resolver/$ts_domain" | |
| if [[ ! -e $stub ]]; then | |
| echo "adding DNS override at $stub" | |
| sudo ${SUDO_ASKPASS:+-A} mkdir -p /etc/resolver | |
| echo "nameserver 100.100.100.100" | sudo ${SUDO_ASKPASS:+-A} tee >/dev/null "$stub" | |
| fi | |
| case $1 in | |
| -f|--flush) | |
| echo "flushing DNS cache" | |
| sudo ${SUDO_ASKPASS:+-A} killall -q -HUP mDNSResponder | |
| sudo ${SUDO_ASKPASS:+-A} dscacheutil -flushcache | |
| ;; | |
| esac | |
| start=$EPOCHSECONDS | |
| # bug should appear after 15 seconds | |
| while true; do | |
| ts_status=$(tailscale status --json | jq -r '.Health | map(select(test("unstable")|not))[] // "healthy"') | |
| case $ts_status in | |
| healthy) : ;; #no-op | |
| *) echo -e "\033[1;31m${ts_status}\033[0m";; | |
| esac | |
| printf 'elapsed: [%3.fs] %s ' $(( EPOCHSECONDS - start )) "querying $peer using dscacheutil:" | |
| dscacheutil -q host -a name "$peer" | grep ip_address || echo '?' | |
| sleep 1 | |
| done |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Install & run
curl -Lso tsbug https://gist.github.com/luckman212/356dfc72396b838a055ec10d315b042b/raw && chmod +x tsbug ./tsbug