I am using an HTTP proxy server to connect to the internet.
Because of that my pings are not working
says Unreachable Host
How can I configure
ping to use the HTTP proxy?
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.Sign up to join this community
In general you can't.
ping needs a direct network connection on the IP level to do its work. A proxy works on a higher layer of the TCP/IP network model, where there is no direct access to the IP protocol.
You would need to somehow circumvent the proxy (change firewall settings, use a VPN, ...). Whether this is possible (and allowed) depends on your network configuration, but it's probably not possible.
As a workaround, there are many web-based ping services available (search for "web-based ping"). These will work.
As others noted,
ping doesn't work through proxy.
But you can use utility
httping for that. It sends a HEAD request (by default) to a web server and measures the time it took to get a response.
httping -x 220.127.116.11:1080 -g http://google.com
➜ ~ httping -g http://google.com -c 3 PING google.com:80 (/): connected to 18.104.22.168:80 (313 bytes), seq=0 time= 38.49 ms connected to 22.214.171.124:80 (313 bytes), seq=1 time= 66.94 ms connected to 126.96.36.199:80 (313 bytes), seq=2 time= 40.79 ms --- http://google.com/ ping statistics --- 3 connects, 3 ok, 0.00% failed, time 3162ms round-trip min/avg/max = 38.5/48.7/66.9 ms
-x- Address of a proxy server, port is optional
-g- URL to send a request to
Other useful options:
-5 - Use SOCKS5. Should be put after the
-x option, i.e.:
httping -x localhost:1080 -5 -g http://google.com
-c- How many probes to send before exiting. Infinite by default.
-G- Do a GET request instead of a HEAD request. That means that also full page/file will be transferred. Note that in this case you're no longer measuring the latency! Useful for testing actual websites.
Be noticed that the time measured also includes the latency introduced by the proxy server itself.
The utility is available through a number of repositories for different OS'es and Linux distros:
sudo apt install httping
sudo apk add httping
macOS with Homebrew:
brew install httping
As another example, I used
httping to estimate latency of my connection to Tor network through Tor proxy:
httping -x localhost:9050 -5 -g http://google.com
The only option I wish
httping had is the ability to ask SOCKS5 proxy for domain name resolution, instead of doing it on its own, which is a more secure way with Tor.
Here is a link to the author's website: