Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
case "$(sw_vers -productVersion)" in
10.5.*|10.6.*)
alias flush_dns="sudo dscacheutil -flushcache"
;;
10.8.*|10.7.*)
alias flush_dns="sudo killall -HUP mDNSResponder"
;;
10.9.*)
alias flush_dns="sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder"
;;
10.10.[123])
alias flush_dns="sudo discoveryutil udnsflushcaches"
;;
10.10.*)
alias flush_dns="sudo killall -HUP mDNSResponder"
;;
esac

barn commented Aug 26, 2015

Lazy approach?

#!/bin/sh
sudo sh -c 'dscacheutil -flushcache ; pkill -HUP mDNSResponder ; discoveryutil udnsflushcaches' 2>/dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment