Skip to content

Instantly share code, notes, and snippets.

@haf
Created May 3, 2014 11:35
Show Gist options
  • Save haf/10241ab9839d784db0dc to your computer and use it in GitHub Desktop.
Save haf/10241ab9839d784db0dc to your computer and use it in GitHub Desktop.
OS X log DNS resolution
P.S. In case anyone is following along at home, here's a bash script that observes the system log to determine which DNS server OS X is using to resolve google.com, for instance:
# enable logging on mDNSResponder
sudo killall -USR1 mDNSResponder
# set logging to the maximum
sudo syslog -c mDNSResponder -d
# start capturing log to a temporary file
syslog -w 0 | grep GetServerForQuestion > /tmp/resolutionquery.log &
# use python to resolve an address using the POSIX API
python -c "import socket;socket.gethostbyname_ex('google.com');"
# stop capturing the log
jobs -p | xargs kill -SIGINT
# shut off increased logging
sudo killall -USR1 mDNSResponder
# display captured output
cat /tmp/resolutionquery.log
Then you look for the log entries for GetServerForQuestion.
From https://lists.apple.com/archives/macnetworkprog/2012/Jul/msg00010.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment