【问题标题】:unable to ping any sites in command line/powershell windows 7无法在命令行/powershell windows 7 中 ping 任何站点
【发布时间】:2016-06-06 09:58:37
【问题描述】:

Windows 命令行是否需要任何代理设置才能 ping 网站?

我可以在浏览器中访问所有网站,但是当我尝试从命令行或 powershell ping 相同的网站时,我收到“请求超时”错误。如何解决这个错误?

在 IE 浏览器中,我设置了一个自动代理检测脚本,因为网络是公司 LAN。尝试了网络中提供的大多数解决方案,但没有任何运气。

因此,我无法运行 chef 命令来安装 gems 并收到错误 Unable to download data from https://rubygems.org/ - Errno::ETIMEDOUT: A connection attempt failed because the connected party did not properly respon d after a period of time, or established connection failed because connected hos t has failed to respond. - connect(2) for "api.rubygems.org" port 443 (https://a pi.rubygems.org/specs.4.8.gz)

【问题讨论】:

  • 很高兴你有tried most of solutions provided in web。如果你能列出你已经尝试过的方法以及它们是如何失败的,那就太好了,这样建议可以集中在尚未尝试过的事情上。

标签: windows powershell command-line proxy chef-infra


【解决方案1】:

获得 ping 回复或 HTTP 响应是完全不同的两件事。也就是说,任何服务器都可以随心所欲地尊重其中任何一个。此外,路由上可能存在更改结果的代理和防火墙。即使服务器愿意回复 ping,公司防火墙也可能会阻止它。

您可能会通过环境变量 as per documentation 设置 Chef 的代理设置取得一些成功。至于如何找出代理设置,请询问您的网络管理员。如果这不起作用,请检索代理设置from IE's registry key。如果链接失效,功能如下:

function Get-InternetProxy { 
    <# 
            .SYNOPSIS 
                Determine the internet proxy address
            .DESCRIPTION
                This function allows you to determine the the internet proxy address used by your computer
            .EXAMPLE 
                Get-InternetProxy
            .Notes 
                Author : Antoine DELRUE 
                WebSite: http://obilan.be 
    #> 

    $proxies = (Get-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings').proxyServer

    if ($proxies) {
        if ($proxies -ilike "*=*") {
            $proxies -replace "=","://" -split(';') | Select-Object -First 1
        } else {
            "http://" + $proxies
        }
    }    
}

【讨论】:

  • 设置系统环境变量帮助我解决了这个问题。谢谢
猜你喜欢
  • 2022-01-17
  • 2022-11-06
  • 1970-01-01
  • 2012-04-28
  • 2013-11-07
  • 2017-03-29
  • 1970-01-01
  • 1970-01-01
  • 2016-04-01
相关资源
最近更新 更多