How does ping work over a proxy?

6

3

I'd changed my machine's proxy to connect to a network, but later when I came back to my home network, while chrome and other browsers could not connect, I could ping sites from the terminal and even install ruby bundles.

Given this, how does the terminal work over a proxy?

More so a proxy that is no longer in use because the network changed.

Projjol

Posted 2015-11-18T13:20:47.540

Reputation: 171

3Best guess: You set up a proxy for port 80 (and port 80 only). So only your webtraffic is redirected via the proxy and only the webtraffic fails if the proxy is down.

As to how to a terminal work ober a proxy: It does not. It simply does not use it. It uses system defaults. And if you only changed proxy settings for/in a browser then there is no reason for ping or any other command to fail. – Hennes – 2015-11-18T13:37:34.980

Answers

14

When you refer to proxies, it’s usually just about HTTP (and HTTPS), sometimes also FTP. Ping does not use HTTP but ICMP. That means it’s not affected by whatever HTTP proxy you set.

Other tools, like wget (a command line HTTP downloader), respect the http_proxy environment variable. This variable may or may not be set when you change the GUI settings. You can easily check by using the env command.

Some command line tools do not use this variable and instead need the proxy to be explicitly specified (as a parameter) each time the tool is started.

Daniel B

Posted 2015-11-18T13:20:47.540

Reputation: 40 502

Proxies are protocol specific. ping uses the ICMP protocol - I've never heard of ICMP proxies but it's not impossible to have one. Web browsers use HTTP. So if an HTTP proxy is down, ping and things using other protocols will work - unless there is a firewall that only allows traffic going through the proxy out. – LawrenceC – 2015-11-18T22:03:57.620

@LawrenceC Proxies are protocol specific Not necessarily. SOCKS proxies, such as those created by Tor and SSH tunnels, are not at all protocol-specific. – Duncan X Simpson – 2015-11-23T19:40:59.260

1@VirtualDXS That's not true. SOCKS, the most basic version, is limited to TCP. It's still specific, just on a different level. – Daniel B – 2015-11-23T20:13:19.530

Not according to this.

– Duncan X Simpson – 2015-12-01T17:50:13.673

That’s why I said “the most basic version”. Yes, SOCKS5 supports UDP. So it was extended to yet another protocol. However, you still won’t be able to use, say, GRE. Or ICMP. It didn’t even support IPv6 before SOCKS5. So yes, SOCKS is still very much protocol-specific. – Daniel B – 2015-12-01T20:35:34.007

2

I think this deserves a simpler answer so here it is.

If you enter the network settings you will see that when configuring the proxy a protocol and port can be specified.

enter image description here

Web browsers generally talk the language of the web server which is HTTP. They can often talk to FTP servers as well. HTTPS is just the encrypted form of HTTP.

As you can see from the dialog, the proxy settings only apply to the HTTP, HTTPS, FTP and SOCKS protocols. Also not all utilities may obey these settings. The major web browsers do though.

So when you brought your computer home and plugged it into your home network, the proxy host(s) are no longer reachable so the web browsers are not able to browse.

However, other apps like ping work because they don't use a proxy at all. In fact, as many have pointed out, ping uses ICMP which is a completely different protocol. Ping will tell you your computer is still able to reach computers on the network. Other utilities that don't use HTTP or don't obey the network proxy settings here may also work as you've discovered.

Matt H

Posted 2015-11-18T13:20:47.540

Reputation: 3 823