Add local DNS forwarder to Windows client
Tomcsanyi, Domonkos
domi at tomcsanyi.net
Tue Nov 10 23:24:59 CET 2020
Hello Yves,
Thanks for your reply. Let me answer each point inline:
> It's not quite that simple. I'll have to find a DNS proxy that does
> what is required to make this scenario work. There is no
> hostname/domain pattern because all hosts on a LAN have no dot in
> them, just names alone. And nobody knows what names are valid in a
> certain network, so all have to be tried.
Sorry to be the critical guy here, but this is not really a well built network. It introduces unnecessary traffic by running queries everywhere and also using hostnames without a tld. However, this is just a sidenote, so again apologies.
> Only one of them should
> resolve for a local name. All of them might resolve for global names.
> If all are equal, that's fine. If not, we have a problem anyway.
>
> But which DNS servers to query depends on what VPN connections are
> active. Only the WG client knows that because it's managing the
> connections/tunnels. A separate DNS proxy would need to query the WG
> state and also know what DNS servers can be found in each tunnel. This
> would best be configured in the tunnel configuration. Anything else
> makes it complicated and error-prone.
Okay, I could understand this fully. Hence I am proposing using a DNS server setting per tunnel. You could point to multiple localhost addresses different tunnels (e.g. Tunnel1 DNS 127.0.0.1, Tunnel2 DNS 127.0.0.2) and configure your forwarder accordingly.
> I really can't imagine why DNS resolution should be very specific.
> Nobody uses DNS in local networks?
We are, certainly. However we use it the way it was designed, with TLDs like .local or similar making it less like your setup which just feels like a blown up NetBIOS.
> Do you access all your LAN machines
> by their IP address? If not, why would you want to do it over a VPN?
> This is basically what you're suggesting.
I must mention that besides regular DNS there are a ton of ways to deal with this both on Linux and Windows. Examples include adding hosts with static IPs to your hosts file, or if you just want to SSH to them using a custom SSH client config with Host/Alias settings could do the job as well. Naturally these are inferior to a well set up DNS server, however they are robust and doing their job fine in many scenarios.
> Imagine you have tunnels to two separate local networks active. How
> would you set things up, on Windows or Linux, to resolve local host
> names from both remote LANs as well as the internet in your default
> browser? Internet names should prefer the local DNS resolver, not go
> through any potentially slow VPN.
Here is my proposal: if you have those tunnels running simultenously you must specify two upstream servers in your local DNS forwarder as well as defining a regular Internet DNS, e.g. 8.8.8.8 or whatever. Then you need to specify that if the domain to be looked up contains a dot then query the Internet DNS, otherwise query both local upstreams.
In case you have only one active tunnel at a time it becomes easier in a way that you could dynamically switch between two configs in sync with changing tunnels as described above.
From the top of my head I cannot name a suitable software for this, but it should be possible to configure this in most resolvers I think.
Me personally as a Python developer would naturally create a quick script in case nothing off the shelf works, since it is not a very complex problem imho.
Cheers,
Domi
>
> -Yves
>
>> Am Di., 10. Nov. 2020 um 09:14 Uhr schrieb Tomcsanyi, Domonkos
>> <domi at tomcsanyi.net>:
>>
>> Hello Yves,
>>
>> I am by no means a person with authority to make such a decision, but your usecase seems to be so specific I would not imagine it would make sense to blow up the size and complexity of the Windows wg with a local DNS forwarder.
>> I think it is way better if people just install a local DNS resolver/forwarder on their own. There a ton of choices available, from simply python scripts to large scale servers. You could easily configure any of these to distinguish which DNS server to ask based on the TLD portion of your local domain or whatever other distinguisher you have.
>> Then the only thing you need to do is tell your system (either via wg or by other means) to use the local resolver and the case is solved :).
>> Also I am pretty sure one of the main philosophies behind wg is to be the same as much as possible on all platforms. Adding a DNS resolver would again mean a lot of complications when compared to e.g. the Linux version, since most Linux distributions already feature some kind of a local resolver by default.
>>
>> Cheers,
>> Domi
>>
>>
>>> 09.11.2020 dátummal, 23:46 időpontban Yves Goergen <yves.goergen at gmail.com> írta:
>>>
>>> Hello,
>>>
>>> I've already used WireGuard to connect to private networks and it's
>>> quite easy once you figure out how to set it up. (Most tutorials are
>>> outdated and haven't been updated, new ones haven't been written.) One
>>> thing that's really missing however is DNS support. All I can do now
>>> is connect to IP addresses. Names are not resolvable on the other
>>> side. If I add the "DNS" directive to my client configuration, it
>>> replaces the local DNS resolver and *all* lookups go to that server
>>> instead. This isn't working either because I'm on two local networks
>>> and each has its own local DNS server that can only resolve its own
>>> local names (and forward the rest to the internet).
>>>
>>> Specifying both networks' DNS servers also fails because when
>>> resolving a name, one of them is chosen at random (and the other one
>>> isn't regarded) and then you won't be able to resolve some of the
>>> names some of the time. This is also very frustrating. And it wouldn't
>>> scale to multiple active tunnels.
>>>
>>> The solution I've read about is to set up a local DNS forwarder that
>>> can be configured so that it uses multiple servers and queries each of
>>> them and returns only a positive response. This way it could query
>>> both local LAN DNS servers and for local names, only one of them would
>>> resolve the name. This is a bit complicated to do if you're not
>>> permanently connected to a VPN, or if you move from one local DHCP
>>> network to another (like with a laptop). And it requires additional
>>> software, setup and configuration, and probably intensive maintenance
>>> and care. All of this makes WireGuard a pretty ugly alternative to
>>> OpenVPN where all of this already works. Despite all the disadvantages
>>> of OpenVPN.
>>>
>>> I'm asking if it's possible to integrate such a local DNS forwarder
>>> into the Windows client application. I imagine it would start up
>>> automatically once the first tunnel is activated. And it would replace
>>> the local system's DNS server setting for as long as it's active (like
>>> the tunnel-configured DNS server already does). And it would query the
>>> original locally configured DNS server and all configured DNS servers
>>> for the active tunnels. It would then be able to resolve local names
>>> and tunnel-remote names without any additional work on the user end.
>>> The user wouldn't have to perform many complex tasks upon activating
>>> or deactivating a tunnel. This would make WireGuard be as simple and
>>> productive as I believe it was intended to be (but isn't yet).
>>>
>>> This probably stops working as soon as other VPN software is used in
>>> parallel, but the current "DNS" setting has the same limitation, it's
>>> better than nothing and most of the time, you only run a single VPN
>>> software.
>>>
>>> Please let me know what you think of it.
>>>
>>> -Yves
More information about the WireGuard
mailing list