admin管理员组文章数量:1618716
友情提示:未必有用。有时候跟网卡配置有关
rm /etc/resolv.conf
vi /etc/resolv.conf
写入下面的内容
nameserver 192.168.2.1
nameserver 114.114.114.114
domain localnet.local
一开始是查Temporary failure in name resolution 的相关问题 ,结果一点用没有,浪费时间
结论:关于WSL2 一定要带上 "WSL2"
转载自
WSL2 Ubuntu: ping: hostname: Temporary failure in name resolution – CT Studio
Now it does what I want it to do. Maybe not what the WSL guys intended, but there you go!
改用外部网络也能解决(缺点,每次开机都要设置)
wsl2 固定ip 和 wsl2 外部网络设置 ,从而解决内部网络的一些问题_viaco2love的博客-CSDN博客_wsl2网络桥接超级管理员查看一下网卡会发现,hyper-v 被勾选了。(上不了网的时候)如果想改回普通模式直接去掉这个勾就行。C:\Users\xxx\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup放一个文件linux-start.vbs内容为Set ws = WScript.CreateObject("WScript.Shell") ws.run "wsl -d Ubuntu...https://blog.csdn/viaco2love/article/details/118100683
github 大佬编写的bat
https://github/microsoft/WSL/issues/4210
wsl2 设置固定ip - 受气de灰太狼 - 博客园
编写一个bat,然后超级管理员运行就行了
wsl2.static.ip.bat 文件内容如下,wsl -d xxx(子系统名称)
wsl -d Ubuntu -u root ip addr del $(ip addr show eth0 ^| grep 'inet\b' ^| awk '{print $2}' ^| head -n 1) dev eth0
wsl -d Ubuntu -u root ip addr add 192.168.50.2/24 broadcast 192.168.50.255 dev eth0
wsl -d Ubuntu -u root ip route add 0.0.0.0/0 via 192.168.50.1 dev eth0
wsl -d Ubuntu -u root echo nameserver 192.168.50.1 ^> /etc/resolv.conf
powershell -c "Get-NetAdapter 'vEthernet (WSL)' | Get-NetIPAddress | Remove-NetIPAddress -Confirm:$False; New-NetIPAddress -IPAddress 192.168.50.1 -PrefixLength 24 -InterfaceAlias 'vEthernet (WSL)'; Get-NetNat | ? Name -Eq WSLNat | Remove-NetNat -Confirm:$False; New-NetNat -Name WSLNat -InternalIPInterfaceAddressPrefix 192.168.50.0/24;"
本文标签: pingUbuntuhostnameResolutionfailure
版权声明:本文标题:WSL2 Ubuntu: ping: hostname: Temporary failure in name resolution 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/xitong/1728785383a1173259.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论