我有适用于 Windows 的 Ubuntu 应用程序(从 Microsoft 商店下载),但我不断遇到名称解析错误的临时故障。
ping: google.com: Temporary failure in name resolution
Run Code Online (Sandbox Code Playgroud)
当我连接到 VPN 和未连接到 VPN 时都会发生这种情况。但是,如果我运行命令:
echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf
Run Code Online (Sandbox Code Playgroud)
然后就解决了未连接VPN的问题。但是,即使运行该命令后,如果我连接到 VPN,它仍然无法工作。
我需要通过 ssh 连接到远程服务器,这需要我使用 VPN 才能访问。因此,我需要确定为什么在连接到 VPN 时没有发生名称解析。即使未连接到 VPN,也最好能永久解决问题,这样我就不必每次都运行上述命令。
该/etc/resolv.conf文件如下所示(在运行上述命令之前):
# 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.22.96.1
Run Code Online (Sandbox Code Playgroud)
我很感激任何想法!