Proxychains Linux Guide: Route Any Application Through Proxies
Proxychains is a Linux tool that forces any TCP connection made by an application to follow through one or more proxy servers. Unlike application-level proxy settings, Proxychains works at the system level using dynamic library injection, meaning it can proxy applications that have no built-in proxy support.
This makes it invaluable for security researchers, web scrapers, and privacy-conscious users who need to route tools like nmap, curl, wget, or custom scripts through SOCKS5 proxies, HTTP proxies, or multi-hop proxy chains.
How Proxychains Works
Proxychains uses the LD_PRELOAD mechanism to intercept networking calls made by applications. When you run a program with proxychains, it loads a shared library that hooks into connect(), send(), and recv() system calls, redirecting them through the configured proxy servers.
Normal: Application -> Direct Connection -> Target Server
Proxychains: Application -> proxychains hook -> Proxy 1 -> Proxy 2 -> Target ServerThis approach means:
- No application modification needed
- Works with any dynamically-linked application
- Supports proxy chaining (multiple proxies in sequence)
- DNS queries can also be proxied (prevents DNS leaks)
Installation
Proxychains-ng (Recommended)
Proxychains-ng is the maintained fork with additional features and bug fixes:
# Ubuntu/Debian
sudo apt install proxychains4
# Fedora/RHEL
sudo dnf install proxychains-ng
# Arch Linux
sudo pacman -S proxychains-ng
# Build from source
git clone https://github.com/rofl0r/proxychains-ng.git
cd proxychains-ng
./configure --prefix=/usr --sysconfdir=/etc
make
sudo make installOriginal Proxychains
# Ubuntu/Debian (older version)
sudo apt install proxychainsConfiguration
The configuration file is located at /etc/proxychains4.conf (or /etc/proxychains.conf for the original version). You can also use a local config file with the -f flag.
Basic Configuration
# /etc/proxychains4.conf
# Proxy chain type
# dynamic_chain - skip dead proxies, at least one must work
# strict_chain - all proxies must be online, order matters
# round_robin_chain - distribute connections across proxies
# random_chain - randomly select proxy for each connection
dynamic_chain
# Proxy DNS requests through the chain (prevents DNS leaks)
proxy_dns
# Timeout settings
tcp_read_time_out 15000
tcp_connect_time_out 8000
# Proxy list
[ProxyList]
# type host port [user pass]
socks5 127.0.0.1 1080
http proxy.example.com 8080 username password
socks4 192.168.1.100 9050Chain Types Explained
| Chain Type | Behavior | Use Case |
|---|---|---|
dynamic_chain | Skips dead proxies, uses remaining | Reliability-focused |
strict_chain | Fails if any proxy is down | Maximum anonymity |
round_robin_chain | Distributes across proxies | Load balancing |
random_chain | Random proxy per connection | Unpredictable patterns |
Using Multiple Proxies
The power of Proxychains lies in chaining multiple proxies together. Each proxy in the chain only knows the previous and next hop, not the full path:
[ProxyList]
# First hop: Local SOCKS5 proxy
socks5 127.0.0.1 9050
# Second hop: Residential proxy
http us-proxy.example.com 8080 user1 pass1
# Third hop: Datacenter proxy in target country
socks5 de-proxy.example.com 1080 user2 pass2With strict_chain, traffic flows: You -> Proxy 1 -> Proxy 2 -> Proxy 3 -> Target.
Basic Usage
Running Applications Through Proxychains
# Basic usage
proxychains4 curl https://httpbin.org/ip
# With custom config file
proxychains4 -f ~/my-proxy-config.conf curl https://example.com
# Force quiet mode (suppress proxychains output)
proxychains4 -q wget https://example.com/file.zip
# Run nmap through proxies
proxychains4 nmap -sT -Pn target.com
# Use with Python scripts
proxychains4 python3 scraper.py
# Use with Node.js
proxychains4 node crawler.js
# SSH through proxies
proxychains4 ssh user@remote-server.comReal-World Examples
Web Scraping with Proxychains
# Run a scraping script through residential proxies
proxychains4 -q python3 -c "
import requests
response = requests.get('https://httpbin.org/ip')
print(response.json())
"Using with wget for Bulk Downloads
# Download multiple files through proxy chain
proxychains4 wget -i urls.txt --wait=2 --random-waitSecurity Scanning
# Run nikto through proxy chain
proxychains4 nikto -h target.com
# DNS enumeration through proxies
proxychains4 dig @8.8.8.8 target.com ANYAdvanced Configuration
Per-Application Configuration
Create different config files for different use cases:
# Config for web scraping (fast, residential proxies)
cat > ~/proxychains-scraping.conf << 'EOF'
dynamic_chain
proxy_dns
tcp_read_time_out 10000
tcp_connect_time_out 5000
[ProxyList]
socks5 residential-proxy.example.com 1080 user pass
EOF
# Config for security testing (multi-hop, maximum anonymity)
cat > ~/proxychains-anon.conf << 'EOF'
strict_chain
proxy_dns
tcp_read_time_out 30000
tcp_connect_time_out 15000
[ProxyList]
socks5 127.0.0.1 9050
socks5 proxy1.example.com 1080 user1 pass1
socks5 proxy2.example.com 1080 user2 pass2
EOF
# Use the appropriate config
proxychains4 -f ~/proxychains-scraping.conf python3 scraper.py
proxychains4 -f ~/proxychains-anon.conf nmap -sT target.comIntegrating with Tor
Proxychains is commonly used with Tor for anonymous traffic routing:
# Install Tor
sudo apt install tor
# Start Tor service (creates SOCKS5 proxy on 9050)
sudo systemctl start tor
# Configure proxychains to use Tor
# /etc/proxychains4.conf
# [ProxyList]
# socks5 127.0.0.1 9050
# Run applications through Tor
proxychains4 curl https://check.torproject.org/api/ipDNS Configuration
By default, Proxychains can leak DNS queries. Enable proxy_dns to route DNS through the proxy chain:
# Prevent DNS leaks
proxy_dnsProxychains with Web Scraping Infrastructure
For large-scale scraping operations, combine Proxychains with proxy rotation and proxy pool management:
#!/bin/bash
# rotate-and-scrape.sh
# Rotate through multiple proxy configs for each scraping batch
CONFIGS=(
~/proxychains-us.conf
~/proxychains-uk.conf
~/proxychains-de.conf
)
for config in "${CONFIGS[@]}"; do
echo "Using config: $config"
proxychains4 -q -f "$config" python3 scraper.py --batch-size 100
sleep 5
doneBuilding a Proxy Config Generator
#!/usr/bin/env python3
"""Generate proxychains config files from a proxy list."""
import sys
TEMPLATE = """dynamic_chain
proxy_dns
tcp_read_time_out 15000
tcp_connect_time_out 8000
[ProxyList]
{proxy_lines}
"""
def generate_config(proxy_list_file, output_file):
proxy_lines = []
with open(proxy_list_file) as f:
for line in f:
line = line.strip()
if not line or line.startswith("#"):
continue
parts = line.split(":")
if len(parts) == 2:
host, port = parts
proxy_lines.append(f"socks5 {host} {port}")
elif len(parts) == 4:
host, port, user, passwd = parts
proxy_lines.append(f"socks5 {host} {port} {user} {passwd}")
config = TEMPLATE.format(proxy_lines="\n".join(proxy_lines))
with open(output_file, "w") as f:
f.write(config)
print(f"Generated config with {len(proxy_lines)} proxies: {output_file}")
if __name__ == "__main__":
generate_config(sys.argv[1], sys.argv[2])Troubleshooting
Common Issues
| Problem | Cause | Solution |
|---|---|---|
| “DLL init” error | Missing library | Install proxychains-ng, not original |
| DNS leaks | proxy_dns not enabled | Add proxy_dns to config |
| Connection timeouts | Proxy is slow/dead | Increase timeout values or use dynamic_chain |
| “Not found” error | Wrong binary name | Use proxychains4 not proxychains |
| Static binaries fail | LD_PRELOAD limitation | Use a SOCKS wrapper like tsocks instead |
Verifying Proxychains Works
# Check your real IP
curl https://httpbin.org/ip
# Check IP through proxychains
proxychains4 -q curl https://httpbin.org/ip
# If IPs are different, proxychains is working correctlyProxychains Alternatives
| Tool | Approach | Pros | Cons |
|---|---|---|---|
| Proxychains-ng | LD_PRELOAD | Works with any app | Linux only, no static binaries |
| tsocks | LD_PRELOAD | Simpler | Less maintained |
| torsocks | LD_PRELOAD | Tor-optimized | Tor only |
| redsocks | iptables redirect | System-wide | More complex setup |
| graftcp | ptrace-based | Works with static binaries | Higher overhead |
For more on proxy types and protocols, see our guides on SOCKS5 vs HTTP proxies and proxy chaining explained.
FAQ
Does Proxychains work on macOS?
Proxychains-ng has limited macOS support. It works with some applications but the DYLD_INSERT_LIBRARIES mechanism is more restricted than Linux’s LD_PRELOAD. For macOS, consider using application-level proxy settings or tools like SwitchyOmega.
Can Proxychains handle UDP traffic?
Proxychains only supports TCP connections. UDP traffic is not proxied and will either fail or go directly. For UDP proxying, use a VPN or SOCKS5 proxy that supports UDP ASSOCIATE.
Is Proxychains detectable?
The proxy servers themselves may be detectable (especially datacenter proxies). However, Proxychains itself does not add any identifying markers to traffic. Use residential proxies for lower detection risk.
Can I use Proxychains with Docker containers?
Yes, but you need to install Proxychains inside the container and configure it there. Alternatively, route the container’s traffic through a host-level proxy using Docker’s network proxy settings.
How many proxies can I chain together?
There is no hard limit, but each additional proxy adds latency. In practice, 2-4 proxies provide a good balance between anonymity and performance. For web scraping, a single high-quality rotating proxy is usually more practical than chaining multiple proxies.
- Datacenter vs Residential Proxies: Complete Comparison
- Docker Proxy Setup: Configure Containers to Use Proxies
- Anti-Bot Detection Glossary: 50+ Terms Defined
- Anti-Bot Terminology Glossary: Complete A-Z Reference 2026
- Backconnect Proxies Deep Dive: Architecture and Real-World Performance
- Best Proxies in Southeast Asia: Singapore, Thailand, Indonesia, Philippines
- Datacenter vs Residential Proxies: Complete Comparison
- Docker Proxy Setup: Configure Containers to Use Proxies
- Anti-Bot Detection Glossary: 50+ Terms Defined
- Anti-Bot Terminology Glossary: Complete A-Z Reference 2026
- Backconnect Proxies Deep Dive: Architecture and Real-World Performance
- Best Proxies in Southeast Asia: Singapore, Thailand, Indonesia, Philippines
- Datacenter vs Residential Proxies: Complete Comparison
- Docker Proxy Setup: Configure Containers to Use Proxies
- 403 Forbidden Error: What It Means & How to Fix It
- 407 Proxy Authentication Required: Fix Guide
- Anti-Bot Detection Glossary: 50+ Terms Defined
- Anti-Bot Terminology Glossary: Complete A-Z Reference 2026
Related Reading
- Datacenter vs Residential Proxies: Complete Comparison
- Docker Proxy Setup: Configure Containers to Use Proxies
- 403 Forbidden Error: What It Means & How to Fix It
- 407 Proxy Authentication Required: Fix Guide
- Anti-Bot Detection Glossary: 50+ Terms Defined
- Anti-Bot Terminology Glossary: Complete A-Z Reference 2026