Repository navigation
net/dns: set WSL resolv.conf - #2252
Conversation
ff6ee7d to
4d1ae05
Compare
| return fs.Rename(tmpName, filename) | ||
| } | ||
|
|
||
| // pinholeFS is a high-level file system abstraction designed just for use |
There was a problem hiding this comment.
I don't get the name. What's pinhole?
There was a problem hiding this comment.
I couldn't think of a name for this. It's an FS, but not a standard open/read/write/close Unix API. It felt like looking through a pinhole. Any better names?
There was a problem hiding this comment.
Took another attempt at the name, wholeFileFS, as you can only work with whole files.
bradfitz
left a comment
There was a problem hiding this comment.
Can you clarify in the commit message whether this is WSL1, WSL2, or both?
| return fs.Rename(tmpName, filename) | ||
| } | ||
|
|
||
| // pinholeFS is a high-level file system abstraction designed just for use |
| } | ||
|
|
||
| const wslConf = "/etc/wsl.conf" | ||
| const wslConfSection = `# added by tailscale |
There was a problem hiding this comment.
hmm, it would probably be good to delete this on uninstall, although that might be tricky if it's edited after; deleting the generateResolvConf line while leaving the section name is probably required
There was a problem hiding this comment.
It would, but it's very problematic. To touch this file, you need to call wsl.exe --shutdown and restart it. On my brand-new machine, that's a multiple second operation that could be disruptive. I'd like to do it zero times.
Open to ideas here, but doing this regularly doesn't seem like a great move.
There was a problem hiding this comment.
If tagged with a special comment, maybe the generateResolvConf line could be deleted by the NSIS uninstaller? That should be sufficiently infrequent.
There was a problem hiding this comment.
That would be infrequent enough for me, though it's a bit of work to make that happen. Would you be fine if I file a bug and do that later?
I suspect it isn't super important because it appears the nature of the generated resolv.conf has shifted over time at MS. The resolv.conf they generate points at a stub resolver on a fixed IP. Nothing I do to my computer's DNS settings change its contents. So I suspect the current behavior of this commit, restoring the backup file, will be adequate.
(That said, we should try and restore the backup on uninstall too.)
This is preliminary work for using the directManager as part of a wslManager on windows, where in addition to configuring windows we'll use wsl.exe to edit the linux file system and modify the system resolv.conf. The pinholeFS is a little funky, but it's designed to work through simple unix tools via wsl.exe without invoking bash. I would not have thought it would stand on its own like this, but it turns out it's useful for writing a test for the directManager. Signed-off-by: David Crawshaw <[email protected]>
We also have to make a one-off change to /etc/wsl.conf to stop every invocation of wsl.exe clobbering the /etc/resolv.conf. This appears to be a safe change to make permanently, as even though the resolv.conf is constantly clobbered, it is always the same stable internal IP that is set as a nameserver. (I believe the resolv.conf clobbering predates the MS stub resolver.) Tested on WSL2, should work for WSL1 too. Fixes #775 Signed-off-by: David Crawshaw <[email protected]>
|
PTAL |
Tested on WSL2, should also work on WSL1.
Fixes #775