How to auto switch DNS settings while connect to different WiFi? I have totally different DNS settings when I am at work and when I am at home. I was wondering can I change my MacBook Pro's DNS settings automatically when I connect to different WiFi.
I did a lot of searches, I made a custom Location called Home in the network settings. And I set my Home DNS settings under this profile. And a default profile called Automatic I let the computer automatically get DNS settings.
After that, I can change my DNS settings through:
networksetup -switchtolocation Home

It is very close to my demand. But I hope I can find a smarter way, If I figure out a method If I connect to a WiFi called &quot;Home&quot;, and then execute the command automatically, It will be excellent.
20200819 Update
I find an automation tool called Hammerspoon, so I can assign a shortcut to switch different Locations using the command.
Although I did not find a direct way, but Hammerspoon is great and powerful. I tried to watch Wifi change using Hammerspoon, but it remains a little problem, so I open an issue here
Keyboard Maestro can do this very easily:

Set the SSID and Location that you want, and that should do what you want.