Change DNS Server From Terminal (or script) on Mac OS X
Problem
How can I change my DNS server from the Terminal on Mac OS X? [I need this because my DNS is not working correctly with my VPN. Sometimes it's using the DNS for my main connection, and sometimes it's using the DNS specified for the VPN (which it should).]
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Fix for: Change DNS Server From Terminal (or script) on Mac OS X
You can use , e.g. for having the Airport connection use Google's DNS Servers: You can find out the name of the network service by running . It'll be 'Wi-Fi' probably. This is the same as if you were to edit the entires in the Network Preference Pane in System Preferences, so it is persistent across reboots. To reset the list of DNS servers, simply pass : To set DNS automatically for multiple services, you can use a script like this, e.g. to use 1.1.1.1's servers: You may be running into a DNS …
Awaiting Verification
Be the first to verify this fix
Sign in to verify this fix