6

I'd like to periodicity check if my SOCKS server is working fine. In order to do that, I thought of pinging 8.8.8.8 (google DNS server) through the SOCKS server.

Is there other recommended way? If it's optimal, how can I ping through SOCKS with python?

iTayb
  • 12,373
  • 24
  • 81
  • 135

4 Answers4

13

A SOCKS proxy provides a TCP proxy service (SOCKS 5 added UDP Support). You cannot perform an ICMP Echo "via" a SOCKS proxy service.

Even if you could, you would be testing ICMP Echo and Echo Reply, and not that your SOCKS server is running fine.

If you want to test that your SOCKS server is "running fine" I'd suggest that you open local listening port and then try to connect to it via the SOCKS service.

MattH
  • 37,273
  • 11
  • 82
  • 84
6

You can use httping to check the network through the SOCKS server instead of the ordinary ping.

ping: send ICMP ECHO_REQUEST packets to network hosts
httping: measure the latency and throughput of a webserver

ICMP works at Layer3(the Network Layer) of the OSI model, SOCKS works at Layer5(the Session Layer), httping works at Layer7(the Application Layer), so ping message cannot pass though the SOCKS, but httping message can.

For example, I setup a shadowsocks(a SOCKS5 proxy) server in a VPS, use my macbook pro as a client using 127.0.0.1:1080, and I want to check if the network to google is good.

httping -x 127.0.0.1:1080 -g http://www.google.com -5

screen capture of httping google through SOCKS5

httping usage httping [options] -5 The proxy server selected is a SOCKS5 server. -g url This selects the url to probe. E.g.: http://localhost/ -x proxyhost[:port] Probe using a proxyserver.

Shawn Wang
  • 761
  • 8
  • 9
3

you can use curl to get some website through that socks, if have the right answer then the socks proxy is all right. For example

curl --socks5 127.0.0.1:1080 ifconfig.me

if you got the warning, then you have unusable socks

curl: (7) Unable to receive initial SOCKS5 response.
flz
  • 122
  • 2
  • 6
0

This is the way I would go about it, and it would probably be most simple to execute your operating system's ping command using a subprocess and parse the output with a regex.


edit

There is an example on activestate that goes most of the way there, you would just have to change the socket to somehow specify your proxy, however that isn't really my area so I'm not sure how you'd go about it.

theheadofabroom
  • 20,639
  • 5
  • 33
  • 65
  • 1
    but i want the ICMP packets to go THROUGH the SOCKS proxy. – iTayb Mar 11 '11 at 15:45
  • I was assuming that you had set up your default connection to route through the SOCKS proxy, in which case surely this would do what you want? Otherwise I think a little more information might be useful :) – theheadofabroom Mar 11 '11 at 15:52
  • 2
    SOCKS 5 proxies provide TCP and UDP services. You can't have your "default route" go via them. You can't ping via them either. – MattH Mar 11 '11 at 15:59
  • SOCKS will not forward ICMP (ping), it's TCP and sometimes UDP only. – Adrien May 27 '16 at 09:11