A client with about 150 macOS called me. They needed to find a quick and effective way to flush DNS cache on macOS Terminal. After brewing a great cup of coffee from Guatelama I decided to take on this one.
I found a simple combination of commands using the macOS Terminal. Once you open your Terminal copy and paste the commands below and press enter:
sudo dscacheutil -flushcache;sudo killall -HUP mDNSResponder
You will not see a success confirmation message on the Terminal. After you run it try to ping or access the desired hostname.
You can even place this command on a bash script and deploy it to all your clients or ever for yourself (maybe create an alias in the Terminal).
Hope this is helpful. Contact me if you have any questions. Also, remember to see my cool T-Shirts and coffee mugs shop where I made my own designs.