2020年10月


在升级到 wsl 2 后发现一些网络问题和之前的 wsl 不一样了,主要是 DNS 解析和 wsl 和 Windows 网络互访问题,这里介绍如何处理。

DNS 解析

wsl 2 使用的 DNS 解析服务器设置在文件:/etc/resolv.conf 内设置,这是一个 link 文件,真正的文件路径是:/run/resolvconf/resolv.conf,这个文件是每次 wsl 启动时自动生成的,内容如下:

# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf:
# [network]
# generateResolvConf = false
nameserver 172.24.144.1

阅读全文


今天将 Windows 10 升级到了 build 2004 版,顺便将 wsl 升级到了 wsl 2,升级教程参考:https://blog.niekun.net/archives/1785.html

运行 wsl 2 时,发现如下报错:

PS C:\Users\Marco Nie> wsl
The attempted operation is not supported for the type of object referenced.

无法正常使用 wsl,查询后得知是由于我正在使用的 proxifier 和 wsl 有了冲突,proxifier 是我一直使用的用来代理程序的应用。在 wsl 的 github 项目讨论中看到有人问了 proxifier 开发者,得到了解决方法,需要使用提供的程序来让 wsl 在运行时不要加载 LSP DLLs。

  • 下载 NoLsp.zip,解压得到 NoLsp.exe
  • 以管理员权限运行 terminal,执行 &"path\to\NoLsp.exe" "c:\windows\system32\wsl.exe"

看到终端显示 Succsess!,表示操作完成,然后 wsl 系统就可以正常打开使用同时不影响 proxifier。

参考链接:https://github.com/microsoft/WSL/issues/4177


在使用 Windows 中有时候会发现某个程序或文件的图标显示不正常,一般是图标缓存的问题,重建一下即可。

以 Windows 10 为例,图标缓存文件路径为:%LOCALAPPDATA%\Microsoft\Windows\Explorer

文件夹内的 iconcache_*.db 就是图标缓存文件,删除这些文件然后重启 explorer 即可。

下面介绍命令的方式处理,使用 power shell 终端:

# 停止 explorer 进程
taskkill /f /im explorer.exe

# 删除缓存图标文件,ps 中使用 $Env:<variable-name> 表达环境变量
del "$env:LOCALAPPDATA\Microsoft\Windows\Explorer\iconcache*.db"

# 重启 explorer
start explorer

完成后查看图标是否已经正常显示。