18

win10连vpn后wsl中dns无法解析的解决方法

 3 years ago
source link: https://sobird.me/win10-vpn-wsl-dns-workaround.htm
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
win10连vpn后wsl中dns无法解析的解决方法 – Sobird

前段时间给自己的win10桌面电脑配置了wsl,今天在连接vpn访问公司内网,在wsl中通过npm install来安装公司某项目的npm包发现公司域名存在dns解析问题。

dnsfix () { /mnt/c/Windows/system32/ipconfig.exe /all | grep --color=auto "DNS Servers" | cut -d ":" -f 2 | grep --color=auto -e '^ [0-9]' | sed 's/^/nameserver/' | sudo tee /etc/resolv.conf > /dev/null }

将上面代码放到.zshrc文件中,执行 source .zshrc,再执行dnsfix命令更新dns即可。

编辑于 2020年9月16日

这篇文章目前没有评论。

姓名: (必填项)

邮箱 (必填项)

博客 (可选)

取消回复

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK