shayne / go-wsl2-host

Automatically update your Windows hosts file with the WSL2 VM IP address
1.65k stars 142 forks source link

WSL 1 IP always 127.0.0.1 & use "LocalSystem" to run service #20

Closed XiaoXice closed 4 years ago

XiaoXice commented 4 years ago

我做了两个修改,一个是 WSL 1 直接使用127.0.0.1作为其IP地址,另一个是使用本地服务来运行,而不是输入用户名密码。 I made two changes, one is using 127.0.0.1 as WSL 1's IP , and the other is to use LocalSystem to run instead of entering the username and password. 我的电脑上同时使用了WSL的两种版本,但是在WSL 1下并没有/proc/net/fib_trie文件,从而导致程序报错,无法运行。因此在获得IP的时候先判断WSL的版本,如果是WSL 1 则直接设置为127.0.0.1。 I use both versions of WSL on my computer. There is no /proc/net/fib_trie file under WSL 1, which causes the program to report errors and fail to run. Therefore, when obtaining the IP, first determine the version of WSL. If it is WSL 1, set it's IP as 127.0.0.1. 我发现并不需要输入用户自己的用户名密码,而且输入的用户名密码还存在会输入错误的情况,同时Windows服务可以使用本地服务的形式安装,所以去掉多余的部分,直接使用本地服务来安装服务并运行。 I found that it is not necessary to input username and password, and those may also be wrong. So remove the extra parts and use LocalSystem to install the service and run it.

XiaoXice commented 4 years ago

直接设置127.0.0.1有待考虑。毕竟这是个地址是本地回路,不是一直是指向WSL1的。 Need to consider about setting WSL1's IP as 127.0.0.1. After all, it's local loop address, not always represent the WSL1.