无法在 Windows 上的 Bash 中 ping

Sil*_*eri 14 bash windows-10 windows-subsystem-for-linux windows-10-v1607

当我尝试运行时:

ping www.google.com
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

ping: icmp open socket: Permission denied
Run Code Online (Sandbox Code Playgroud)

跑步sudo并没有什么区别。

Sil*_*eri 24

更新:Windows 10 创意者更新(2017 年 4 月)以来,此问题已得到修复。Windows 上的 Bash 不再需要管理员权限来执行 ping 命令。

“Windows TCP/IP 堆栈需要管理员权限才能打开 RAW 套接字以采取安全措施”[来源]。请参阅MSDN 帖子。这仅适用于低级网络协议,例如ping.

以管理员身份运行“Windows 上的 Bash”shell 应该允许 ping 命令工作。只需右键单击它的快捷方式并选择选项:

为 Bash 开始菜单快捷方式选择“以管理员身份运行”

这仅适用于使用这些权限打开的单个会话。

如果其他命令也无法连接到 Internet(例如apt-get, wget),那么您可能还需要查看Internet access not working in Windows Subsystem for Linux