After using `networksetup -setdnsservers Wi-Fi "8.8.8.8" "8.8.4.4"` how do I clear them? I'm looking to script a temporary DNS server change to override the DHCP response I get from the network. I've figured out I can use networksetup but once we're done testing. Before I push to production, I figure I should know how to undo this.

How can I script to clear these changes and restore the settings the network provides now as if I never ran the following script?

networksetup -setdnsservers Wi-Fi "8.8.8.8" "8.8.4.4"


It's not feasible to save any the previous settings and I'm looking to remove the setting so that the actual new values can be retrieved from the network as opposed to saving what the settings were previously so I don't save an old value that is no longer correct.

Basically, I'm looking to ipconfig /renew on macOS.
If you're concerned only about cleaning DNS entries, the  command help gives you instructions what to do:

Usage: networksetup -setdnsservers &lt;networkservice&gt; &lt;dns1&gt; [dns2] [...]
       Set the &lt;networkservice&gt; DNS servers to &lt;dns1&gt; [dns2] [...]. Any 
       number of dns servers can be specified. Specify "Empty" for &lt;dns1&gt; 
       to clear all DNS entries.


In my case

sudo networksetup -setdnsservers Wi-Fi "Empty"