Change DNS servers from the command line in Mac OS X

Changing DNS servers isn’t something most people need to do frequently. When you do need to change them up, though, it takes too many clicks in System Preferences. Use networksetup at the command line instead. For example, to change your DNS server to the OpenDNS servers, issue the following (if you’re using Ethernet): sudo networksetup …