Run any program through a SOCKS proxy (chain)

proxychains-ng enables you to easily route any program trough a proxy (chain) without the need to work yourself through tons of man pages and parameter lists.

git clone https://github.com/rofl0r/proxychains-ng.git
cd proxychains-ng/
./configure --prefix=/usr/
make
sudo make install

After installing you can either create a default config at /etc/proxychains.conf or pass a custom location/file using -f <filename>. A sample config is located at src/proxychains.conf, which can be installed at the default location using sudo make install-config.

strict_chain #chain proxies in the order as they appear in the list (all proxies must be online)
proxy_dns #proxy DNS requests
remote_dns_subnet 224 #subnet for internal remote DNS mapping
# Some timeouts in milliseconds (defaults)
tcp_read_time_out 15000
tcp_connect_time_out 8000
chain_len=1 # Chain length

[ProxyList]
socks5 127.0.0.1 1080 # shadowsocks
socks4 127.0.0.1 9050 # tor
http   somehost  8080 <user> <password> # http

proxychains-ng supports different chaining modes:

  • strict_chain: use all proxies in the order they appear in the config
    • all must be online
  • dynamic_chain: use all online proxies in the order they appear
    • at least one must be online
  • round_robin_chain: proxy chain of online proxies with a length of chain_len
    • Previously used servers are skipped/used as an offset for round robin
  • random_chain: as the name says… random proxy chain with a length of chain_len

Using proxychains-ng is as simple as:

proxychains4 wget <url>
proxychains4 -f <file.conf> ssh user@host