Apple - After using `networksetup -setdnsservers Wi-Fi "8.8.8.8" "8.8.4.4"` how do I clear them?
If you're concerned only about cleaning DNS entries, the command help gives you instructions what to do:
Usage: networksetup -setdnsservers <networkservice> <dns1> [dns2] [...]
Set the <networkservice> DNS servers to <dns1> [dns2] [...]. Any
number of dns servers can be specified. Specify "Empty" for <dns1>
to clear all DNS entries.
In my case
sudo networksetup -setdnsservers Wi-Fi "Empty"
Create a new network service with the respective interface (e.g. en1 = AirPort):
sudo networksetup -createnetworkservice Wi-Fi2 en1
Remove the one with the custom DNS settings:
sudo networksetup -removenetworkservice Wi-Fi
Rename the new network service to the original name:
sudo networksetup -renamenetworkservice Wi-Fi2 Wi-Fi
In my environment the new service fetched DHCP and its new settings automatically. You may have to set it with sudo networksetup -setdhcp Wi-Fi
explicitly or look at the DHCP response for the interface and parse the supplied DNS ip(s) with ipconfig getpacket en1
though.