Where can I force a specific DNS server to be used on OS X?

On OS X Leopard, scutil gives me

$ scutil --dns
DNS configuration

resolver #1
  nameserver[0] : 192.168.1.1
  nameserver[1] : 192.168.2.1
  order   : 200000

resolver #2
  domain : local
  options : mdns
  timeout : 2
  order   : 300000

...

Now, how do I remove the first "resolver #1" and replace with a DNS server of my choosing?


Context: A VPN client sets this bogus DNS entry on connection, replacing my working DNS settings. I haven't been able to figure out how to stop it from doing so (see here), so now I'm trying to remove this unwanted effect ex-post, after I connect. A command line script to do this would be perfect.

I tried sudo scutil as per instructions here, but no love -- scutil --dns still reports the settings unchanged, and DNS resolution still doesn't work. Modifying /etc/resolv.conf has no effect on OS X.


In my experience if you specify a particular DNS server in Network preferences, even if you're using DHCP, Mac OS uses that server in preference to the one obtained through DHCP. So if you always want to use 192.168.1.1, put that in explicitly.

System Preferences -> Network -> Ethernet (left pane) should produce a window that has a "DNS Server:" text box you can fill in with the IP address of your desired DNS server. Click "Apply" to apply the change, and you're done; you shouldn't have to make this change again. (If your VPN connection is WiFi instead of Ethernet, then you should click on that instead of Ethernet above.)


For temporary override on command line you can do:

sudo networksetup -setdnsservers Wi-Fi <dnsserver1ip> <dnsserver2ip>

and reset settings with:

sudo networksetup -setdnsservers Wi-Fi empty

If connected with some other interface than Wi-fi you can check valid names with:

sudo networksetup -listallnetworkservices

Well, most VPN connections I am aware of are able to push a DNS server to the VPN client. My suggestion would be to ask your VPN provider to not push the DNS server for your connection. Please note that this might have some negative impact on your VPN session.