-
Notifications
You must be signed in to change notification settings - Fork 798
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
/etc/hosts being recreated each time I restart. #398
Comments
i-frost, doesn't it get imported on bash.exe startup by the C:\Windows\System32\etc\hosts file? Microsoft said that they're trying to have the base environment make use of Windows resources as much as possible, and likely this includes /etc/hosts. |
I tried adding the details to the Windows hosts file but bash does not pick i-frost, doesn't it get provided by the C:\Windows\System32\etc\hosts file? — |
Could you do the following workaround until they fix it: Add the line to .bashrc |
Hey I tried adding it to .bashrc but I just get permission denied when i start I then tried adding my user name to sudoers and setting NOPASSWD but this I thought this would save my bacon as I cannot get this laptop to work with Thanks On Thu, May 19, 2016 at 6:27 PM, fpqc notifications@github.com wrote:
|
You tried the original thing I wrote (which was wrong), or the corrected one? The thing I think will work in bash.rc is actually |
I'm taking a look at a way to work around this. My current thinking is to add a header to the top of /etc/hosts that says something like:
That way if you don't want WSL to automatically generate this file you'll be able to remove the header. If you want WSL to regenerate the file you can either delete the file or add back the header. @i-frost @fpqc Does this sound like a decent solution to you? |
Sounds good to me:-) Thanks Ben! |
@benhillis I guess! Wouldn't a good solution also be to have it just read the Windows HOSTS file as a device called like /dev/hosts (or a process called /proc/hosts) and then make /etc/hosts a symlink? That's how you guys are doing it for outputting memory management info, at least. I think that's a good idea. The more you rely on Windows-provided stuff, the fewer weird problems you'll have where you have to configure things twice, once for Windows and once for WSL. |
@fpqc - I'm not sure that will work because the hosts files are different formats. Linux host files are tab separated and Windows are space separated, for example. |
@benhillis I don't doubt the abilities of you guys at Microsoft to parse and reformat the HOSTS file =), but it's up to you! |
On Fri, May 20, 2016 at 11:09 AM, Ben Hillis notifications@github.com
Better to have a line with instructions to change Yes (default) to No: WSL Update etc/hosts YesWSL Update etc/hosts NoDeletion of the comment defaults to Yes. The hosts file is one way to abuse internet connections.
T o m M i t c h e l l |
@niftyhacking If the /etc/hosts file is deleted, a new one will be auto-generated (with the comment). I've checked in a fix for this and it will be making its way to the Windows Insider fast ring in a future build (a few weeks out likely). |
Thank you. T o m M i t c h e l l |
Ben's fix made it into build 14361. |
Thank you so much:-)
|
@benhillis , this solutions feels wrong to me. It seems that if you add something to your hosts file, you would want it to work both Windows side, and in WSL. I often use localhost IP's over ssh tunnels and prefer having aliases for each. I have this in my hosts:
Then have an ssh tunnel:
Allowing me to access remote desktop to Am I missing something? Perhaps you could add a second option to use windows hosts? Currently using:
|
Looks like #2059 states:
|
(if anyone else finds this thread on google like me, adding windows hosts to /etc/hosts is now in the regular builds) |
Hello, I'm running build 16299 and the comment I have in /etc/hosts is diferent:
In my use case, I don't want to modify Windows's hosts file, just the WSL one ! So adding the entries in Windows's hosts file is not an option for me ! Ideally a "diff" mechanism between Windows and WSL whould be IMHO the best approach.. Regards, PS: I'm running Debian in my WSL |
This is configurable via the wsl.conf setting 'generateHosts'. |
Hi
I want to add the names of my machines and ip addr to the hosts file in /etc but after a reboot the file is recreated thus wiping the changes I added.
I tried adding the IP addr and names to the windows hosts file in windows/system32/drivers/etc/hosts
But it doesn't then pick up the IP addr in the bash shell.
Is this possible as I don't want to have to keep typing in the ip addr to use ssh?
Thanks
The text was updated successfully, but these errors were encountered: