简体   繁体   中英

unable to ping any sites in command line/powershell windows 7

Does windows command line requires any proxy setting to ping websites?

I can access all websites in my browser but when I try to ping the same from commandline or powershell I get "Request timed out" error. How to resolve this error?

In IE browser I've set a automatic proxy detection script as the network is company LAN. Tried most of solutions provided in web without any luck.

Due to this I am unable to run the chef commands to install gems and receiving error 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) 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)

Getting a ping reply or HTTP response are two entirely different things. That is, any server can honor either of those just as well as it pleases. In addition, there might be proxies and firewalls on the route that change the results. Even if a server is willing to reply on ping, corporate firewall might block it.

You might have some success with setting Chef's proxy settings via environment variables, as per documentation . As how to find out the proxy settings, ask your network admin. If that doesn't work, retrieve the proxy settings from IE's registry key . In case of link rot, here's the function:

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
        }
    }    
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM