Socks5 proxy and wget


I’ve tried to set wget bash loop over socks5 proxy and was surprised to find out that wget does not have included proxy support. First start your proxy tunnel on port 8080 with

ssh -o "ServerAliveInterval 60" -o "ServerAliveCountMax 3" -f -C -N -D *:8080 user@my.proxy.server &> tunnel.log

My firefox utilizes this tunnel perfectly – the proxy config page has the following entries:

  Manual proxy configuration:
    SOCKS Proxy  127.0.0.1  Port 8080
    "SOCKS v5"  checked

Initially I’ve tried using wget –execute to set http_proxy with

wget -e "http_proxy = 127.0.0.1:8080" "http://url_to_get"

however it didn’t work giving me the following error.

Connecting to 127.0.0.1:8080... connected.
Proxy request sent, awaiting response... No data received.
Retrying.

Wget with Tsocks

The solution was to install tsocks. For gentoo just do

emerge -av tsocks

and modify the config file. Note that gentoo keeps the confing information in /etc/socks/tsocks.conf, while ubuntu keeps it in /etc/tsocks.conf

nano -w /etc/socks/tsocks.conf

server = 127.0.0.1
server_type = 5
server_port = 8080

If you used proxy on earlier versions of wget, remove any proxy cmds from ~/.wgetrc

Finally start your wget trough socks5 proxy using tsocks

tsocks wget http://url_to_get

starting two tsocks wget at the same time caused my system to slow down and gave me the following error:

Connecting to www.ccc.ccccc|192.xxx.xxx.xxxx|:443... failed: 
Transport endpoint is not connected.

After killing one of the processes, I got back my cpu.

Do you wanna do more? Try Tor.

, , ,