OpenVPN: Update Client DNS Servers on Mac OS X Using the Command Line.

There’s a bit of a debate on how best to update your DNS resolver on Mac OS X when connecting to an OpenVPN Server. For whatever reason, even if use DHCP on the VPN server, OS X won’t use the assigned DNS server(s). It’s been recommended to use scutil, but the scripts are crazy long and I’ve read the resolver order sometimes gets reset anyway.

The usual route of using /etc/resolv.conf does not work on OS X but specifying DNS servers in your Network Preferences does. If you use public network servers like 8.8.8.8 or 4.2.2.2, you’re already set. Move along :) But if you rely on DHCP assigned DNS servers, the the script below will do the trick. This script specifies or clears (sets back to DHCP default) the DNS servers on each of the adapters listed in networksetup.

Again, if you already set your DNS servers, your OpenVPN connection will use those. This script is effective for people who use DHCP assigned DNS servers by default and would like to tunnel their DNS requests when connecting to an OpenVPN server.

Chrissy is a Cloud and Datacenter Management & Data Platform MVP who has worked in IT for over 20 years. She is the creator of the popular SQL PowerShell module dbatools, and holds a number of certifications, including those relating to SQL Server, Linux, SharePoint and network security. You can follow her on Twitter at @cl.

Posted in Networking, OS X & iPhone
0 comments on “OpenVPN: Update Client DNS Servers on Mac OS X Using the Command Line.
1 Pings/Trackbacks for "OpenVPN: Update Client DNS Servers on Mac OS X Using the Command Line."
  1. […] out this post on updating client-side DNS servers if you'd like to update all of your adapters instead of the ones most often used (Ethernet and […]

Leave a Reply

Your email address will not be published. Required fields are marked *

*