3

I have a domain (example.com) which is setup to have two views. host1.example.com will be 10.0.0.1 in an internal network and 149.120.10.14 (a public IP) when queried from outside.

This means that a device connected to Internet should have its usual set of DNSes used normally (the ones it gets from DHCP, say 8.8.8.8) and they will resolve host1.example.com to its external IP.

When connected via VPN, this device should however receive from the OpenVPN server a specific DNS to resolve example.com (and only example.com).

My understading is that using

push "dhcp-option DNS 10.10.10.100"

where 10.10.10.100 is the internal, VPN reachable DNS server would overwrite the DNS servers on the device, loosing the ones it already had.

Is there a way to push a DNS nameserver with the option to use it only for a specific domain and retain the existing other DNSes (used for Internet/company resolution)?

2 Answers 2

3

This is not possible. But here is a workaround.

Setup a DNS server inside your VPN network and use it as DNS server for all VPN users.

On this DNS server, setup primary zone for your specific domain name (example.com) with the internal IP addresses. And setup DNS redirection to run DNS queries which the DNS server can't handle itself.

In this case, all DNS queries on the zone example.com will use DNS records from your server and all other DNS queries will be solved by 8.8.8.8 for example.

3
  • This is what I have today. The problem is that when I am in a place A, I get via DHCP the DNSes allowing me to resolve A's internal network and Internet. With your solution, i would get the DNS of the VPN network (place B) which resolves B's internal networks and Internet. I lose the ability to resolve A's names. Thus my quest for a domain-specific resolution in the VPN-provided DNS (keeping the local (A) DNSes as well)
    – WoJ
    Apr 12, 2018 at 6:53
  • Setup A's zone (secondary DNS) on B's DNS server.
    – Neutrinou
    Apr 12, 2018 at 8:54
  • OK, now that I actually understood (yes, it took me time :)) what you mean - this is a very good solution. I set a forwarding of zone A (to its DNS servers) on the DNS I want to query and it works great. Thank you!
    – WoJ
    Mar 7, 2019 at 13:05
1

Unfortunately, this is not possible, as the DNS resolving itself is done by the Client OS (just to be configured dynamically by OpenVPN), and all widely-used Client OS wouldn't be able to do different name resolution on a per-domain basis.

You must log in to answer this question.

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