Using the chosen answer in this superuser article I've setup my mac to only send VPN traffic through the VPN. This allows me to use my office internet connection directly and not direct everything through the VPN connection.

So anything looking for an IP on 192.168.x.x is routed to the VPN. Anything else is sent to the normal internet connection.

However, the downside is that I can't use the DNS server they use for the VPN, so I have to maintain a hosts file entry for example.mycompany.com. The network admin will no longer be sharing what the IPs are, and is requiring that I use the DNS server.

How can I instruct my system to use a different DNS server if the domain name matches a pattern?

OS X Mavericks

3 Answers 3


If you install DNSMasq on your system, which appears to be possible. Then you can configure it to direct request to DNS servers based on the domain. Your configuration would look somewhat like this.

# Google DNS by default

# add dns servers for work networks

I don't think you can do what you want very easily. You could probably setup your own local DNS server which could then make those decisions for you.

A more simple solution might be to just use the DNS server on the VPN always. That DNS server should be able to resolve Internet domains as well as local domains and traffic bound for Internet IP address will continue to use your regular Internet connection.


Sounds like you are looking for whats called a Proxy. There you can add roules based on URL's.

like this:

A minimal PAC file that always sends you to the proxy server proxy.companyname on port 81:

function FindProxyForURL(url, host)
    if (url = url1) return "PROXY proxy1.companyname:8080";
    if (url = url2) return "PROXY proxy2.companyname:8080";

have a look here: Can I make Windows 7 change my proxy settings based on my network connection?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .