Flush Dns on Mac

Scripting makes things easy. For the most part...

Gah, they make everything so hard. (I need to run two simple commands.) Why cant I just run one command and flush the dns on my mac? Well im sure theres a better way to do this… (there is)

Welcome to flushdns(.sh)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/bash
# This script will clear your dns cache on your mac. It has been tested on macOS 13.4 Ventura
# Joshua Winters-Brown

if [ "$EUID" -ne 0 ]
    then echo "Please run this program as root, otherwise it will not work appropriately."
    exit
fi

dscacheutil -flushcache; killall -HUP mDNSResponder > /dev/null

echo "  _____ "
echo "  |   D "
echo "  |   | "
echo "  |   | "
echo "  \___|            _ "
echo "    ||  _______  -( (- "
echo "    |_'(-------)  '-' "
echo "       |       / "
echo " _____,-\__..__|_____ "
echo " "
echo " Your DNS has been flushed... "

Throw this script into your /usr/local/bin and you can run flushdns from anywhere in the terminal.

Tada!

Licensed under GNU General Public License v3.0
Built with Hugo
Theme Stack designed by Jimmy