Skip to content

Instantly share code, notes, and snippets.

@xv-tom-l
Last active August 29, 2015 14:14
Show Gist options
  • Save xv-tom-l/2a9eaf51923fb310e1f4 to your computer and use it in GitHub Desktop.
Save xv-tom-l/2a9eaf51923fb310e1f4 to your computer and use it in GitHub Desktop.
Shell script for troubleshooting DNS issue on Mac OS X
#!/bin/bash -e
# Troubleshooting DNS issue on Mac OS X
LOGFILE=/tmp/dns_troubleshooter_$(date +%Y-%m-%d).log
function run() {
echo "## interfaces: ifconfig -a"
ifconfig -a
echo
echo "## dns settings"
scutil --dns
echo
echo "## routing table: netstat -rn"
netstat -rn
echo
echo "## traceroute 8.8.8.8"
traceroute 8.8.8.8
echo
echo "## nslookup google.com"
nslookup google.com
echo
echo "## nslookup baidu.cn"
nslookup baidu.cn
echo
echo "DONE"
}
run 2>&1 | tee "$LOGFILE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment