Use VPN DNS only for domains matching a pattern, otherwise continue to use ISP dns

2

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

BotskoNet

Posted 2013-12-19T18:05:34.720

Reputation: 81

Answers

4

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
server=8.8.8.8
server=8.8.4.4

# add dns servers for work networks
server=/example.org/10.in-addr.arpa/10.2.2.11
server=/example.org/10.in-addr.arpa/10.2.2.12

Zoredache

Posted 2013-12-19T18:05:34.720

Reputation: 18 453

2

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.

heavyd

Posted 2013-12-19T18:05:34.720

Reputation: 54 755

0

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?

konqui

Posted 2013-12-19T18:05:34.720

Reputation: 504