小编Ike*_*kwu的帖子

启动时使用 WSL IP 更新 Windows“主机”文件

我在 Windows 10 上使用 WSL2。

我的发行版是 Debian。

我想为我的发行版设置静态 IP,但我发现从这个答案中无法为 WSL 完成此操作。

但我发现可能还有其他一些可能性。

是否可以有一个 Powershell 脚本来更新 Windows 10 上的 etc 主机,并使用指向自定义域名的新 WSL IP(如172.18.225.26 dev.local启动时那样)?并且不会在主机文件上留下任何先前的 WSL 配置。

我的主机文件当前如下所示:

# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in …
Run Code Online (Sandbox Code Playgroud)

powershell windows-10 windows-subsystem-for-linux

6
推荐指数
1
解决办法
7568
查看次数