# Clear DNS cache
$ sudo killall -HUP mDNSResponder
# Restart MacOS re-opening all programs as they were before
$ osascript -e 'tell application "System Events" to restart'
# Restart wifi adapter
$ networksetup -setairportpower en0 off && networksetup -setairportpower en0 on