Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manual override of /etc/resolv.conf for custom DNS setups #1055

Closed
gjonespf opened this issue Sep 6, 2016 · 5 comments
Closed

Manual override of /etc/resolv.conf for custom DNS setups #1055

gjonespf opened this issue Sep 6, 2016 · 5 comments

Comments

@gjonespf
Copy link

gjonespf commented Sep 6, 2016

Using:
Microsoft Windows [Version 10.0.14393]

Currently, /etc/resolv.conf is autogenerated - which is perfect for most situations. I'm annoying, however, and run a local DNS server on my dev boxes to allow custom DNS overrides. So for

ipconfig /all

I get several DNS servers, e.g. one public:
8.8.8.8

and one custom loopback
10.99.1.1

These are autogenerated into the resolv.conf:
nameserver 8.8.8.8
nameserver 10.99.1.1
search Home

Problem is, when I try to resolve any custom domain, it'll resolve using the first one and fail. I kinda want to remove the first nameserver, and just use my custom local one which also does caching from public servers:

nameserver 10.99.1.1
search Home

So ultimately I need some way of overriding /etc/resolv.conf autogeneration, or disabling it.

I've tried using resolvconf, expecting this may be used to update the conf:

sudo resolvconf --disable-updates
resolvconf: Error: /run/resolvconf/interface either does not exist or is not a directory

Have also looked into modifying:
/etc/network/interfaces.d/eth0.cfg

auto eth0
iface eth0 inet dhcp
dns-search Home
dns-nameservers 10.99.1.1

Have also tried modifying the dhcpclient stuff, no avail.

@rodrymbo
Copy link

rodrymbo commented Sep 8, 2016

Since /etc/resolv.conf is autogenerated by a Windows process (not by Linux), using Linux tools is not going to help much. Windows handles all networking except DNS, and the usual networking tools don't work (yet?). Actually the only networking function Windows doesn't do in real time is put a nameserver in /etc/resolv.conf; it just does that once per session. Applications read a nameserver from resolv.conf, and then use Windows networking to connect to the resolver.

About the only way to fix it (until more options become available) is to tell the Windows side to use your custom name resolver, or at least put it first. With a bit of luck the autogenerated /etc/resolv.conf might then put your custom resolver first, with the public one second, and it will work as you want. Perhaps someone knows how the autogeneration process chooses which nameservers from which adapters on the Windows side are put first in /etc/resolv.conf, if the obvious changes don't work.

Or I suppose you could put a script in .bashrc or something that overwrites the autogenerated resolv.conf with one more to your liking every time you log in, until such time as WSL gives more options.

(Actually it would have been nice for a failure in the public resolver to result in fall through to the next resolver on the list. Not sure why that doesn't happen, though there is probably a good explanation somewhere, like perhaps the public resolver actually giving a result instead of failure.)

@sunilmut
Copy link
Member

@gjonespf Please see #1028 on how WSL currently does DNS and our thoughts around it (and the issue with not keeping DNS entry not in sync between Windows and WSL). In short, and, also as @rodrymbo points out, the way currently to manage your /etc/resolv.conf is by updating your Windows DNS entries. Hopefully, we can soon fix the issue that is preventing the WSL DNS entries to stay in sync with the Windows side, on a continuous basis. As a workaround, a fresh bash launch should regenerate the /etc/resolv.conf.

@gjonespf
Copy link
Author

@sunilmut Yeah, for now I've just removed all public DNS from the Windows side and run everything with caching through custom local DNS server/proxy. It's a little simpler to debug that way.
@rodrymbo cheers for the info, it's a little difficult to know how much WSL uses the Linux/Ubuntu networking model, so thought I'd try. And yeah, the .bashrc idea also works, tried that before just simplifying DNS resolution on the Windows side. Will close this as I'd imagine the work around will work for most people.

@ghost
Copy link

ghost commented Jan 28, 2017

anyone know how this is fixed in the insider builds?

@rehangit
Copy link

rehangit commented Oct 23, 2018

  1. In bash/wsl add 8.8.8.8 as first entry in resolv.conf (sudo nano /etc/resolv.conf)
  2. For dos use these instructions to use google dns (8.8.8.8)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants