I have a problem with trying to set up some DNS servers (these are for
local DNS serving, and are not publicly accessible). I don't know if it
is possible to do what I want here, and I'd value any advice on how to
do it, or suggestions on what else I could try.
First, here is the "company" network:
router: eth0 connected to internet, with global IP (say, 20.0.0.1)
eth1 connected to internal LAN, IP 10.0.0.1
running dnsmasq for local queries, resolving local names and
caching lookups from ISP's DNS servers.
openvpn server
Incoming port 80 traffic on eth0 forwarded to "http"
http: IP 10.0.0.2
Running apache, with name-based virtual hosting. Everything
addressed to "www.company.com" is forwarded to "www", and
everything addressed to "www2.company.com" forwarded to "www2"
www: IP 10.0.0.3
Web server
www2: IP 10.0.0.4
Another web server
officeclient: IP 10.0.0.5
On a public DNS server, all "*.company.com" addresses resolve to the
global 20.0.0.1
Home network:
homerouter:
global IP 20.0.0.2, lan ip 10.1.0.1
running dnsmasq for local queries, resolving local names and
caching lookups from ISP's DNS servers.
homeserver:
ip 10.1.0.2
homeclient: ip 10.1.0.3
Sometimes running openvpn, connecting to router.company.com
When "officeclient" looks for "www.company.com", the dnsmasq on "router"
resolves it to 10.0.0.3, and "officeclient" gets direct access by web
browser, ssh, nfs, or whatever.
When "homeclient" looks for "www.company.com", the dnsmasq on
"homerouter" passes the query to the ISP's DNS server, which returns
20.0.0.1. Web access will be forwarded by "router" to "http", which
will pass on the request to "www". If "homeclient" tries "ssh
www.company.com", it will actually target "router", which will reject
incoming ssh traffic.
So far, this is exactly what I want, and works fine.
When "homeclient" connects with openvpn to "router", it then has direct
access to the internal servers. "ssh 10.0.0.3" gives "homeclient" ssh
access to "www".
If the openvpn server is configured to push its DNS server to the
client, then "homeclient" will use "router"'s DNS server. Then
"www.company.com" will resolve to 10.0.0.3, and homeclient has direct
access to the "company.com" machines by name. However, attempts to
lookup "homeserver" will fail as "router" does not know about "homeserver".
If the openvpn server does not pass on its DNS server, "homeclient"
cannot access the internal company machines by name - "www.company.com"
will still resolve to 20.0.0.1. However, lookups of "homeserver" will
work fine.
What I would really like is for "homeclient" to use /both/ dns servers
when the vpn is connected. I want "company.com" names to be searched on
"router" (over the vpn), and other names looked up locally on "homerouter".
Is there any way I can get this sort of flexibility? I'm beginning to
think the only way to get close is to put "homeserver" in the hosts file
on "homeclient", and let the vpn server push the DNS server to
"homeclient" when it is connected.