Automatically use a proxy to solve network problems - When encountering network connection failures, timeouts, or restricted access, automatically use proxychains4 to force traffic through the proxy.
When to Use This Skill
Trigger conditions (automatically applied):
- ❌ Connection timeout errors
- ❌ DNS resolution failures
- ❌ "Connection refused" errors
- ❌ HTTP 403/451 blocked access
- ❌ Access failures to foreign resources such as GitHub/PyPI/npm
- ❌ Failures of commands such as curl/wget/git/pip
Claude should:
- After detecting a network error, automatically add
proxychains4 - before the command, using the default proxy configuration:
http://127.0.0.1:9910 - If the proxy fails, prompt the user to check the proxy service status
Quick Reference
Basic usage patterns
# ❌ 原命令失败
curl https://github.com/user/repo
# ✅ 使用代理重试
proxychains4 curl https://github.com/user/repo
Automatic application in common scenarios
Scenario 1: Git operation fails
# 原命令
git clone https://github.com/user/repo.git
# 自动改为
proxychains4 git clone https://github.com/user/repo.git
Scenario 2: Python pip installation fails
# 原命令
pip install requests
# 自动改为
proxychains4 pip install requests
Scenario 3: npm/yarn installation fails
# 原命令
npm install package-name
# 自动改为
proxychains4 npm install package-name
Scenario 4: wget/curl download fails
# 原命令
wget https://example.com/file.tar.gz
# 自动改为
proxychains4 wget https://example.com/file.tar.gz
Scenario 5: Docker image pull fails
# 原命令
docker pull image:tag
# 自动改为
proxychains4 docker pull image:tag
Scenario 6: SSH connection fails
# 原命令
ssh user@remote-host
# 自动改为
proxychains4 ssh user@remote-host
Configuration details
Default proxy configuration
Local proxy address: http://127.0.0.1:9910
Configuration file location:
~/.proxychains/proxychains.conf(recommended)/etc/proxychains.conf(system-level)
Quick configuration script
Create a user-level configuration (automatically uses 127.0.0.1:9910):
mkdir -p ~/.proxychains
cat > ~/.proxychains/proxychains.conf << 'EOF'
# Proxychains configuration
strict_chain
proxy_dns
remote_dns_subnet 224
tcp_read_time_out 15000
tcp_connect_time_out 8000
[ProxyList]
http 127.0.0.1 9910
EOF
Environment variable method (temporary use)
# 设置代理环境变量
export PROXYCHAINS_SOCKS5_HOST=127.0.0.1
export PROXYCHAINS_SOCKS5_PORT=9910
# 使用
proxychains4 curl https://github.com
How it works
Proxychains intercepts a program's network calls through the LD_PRELOAD mechanism:
- Intercept system calls: Hook socket-related libc functions
- Redirect connections: Redirect all TCP connections to the proxy server
- DNS proxy: Resolve domain names through the proxy server
- Transparent proxy: No application modification required
Important limitations:
- Only supports dynamically linked programs (statically linked programs are not supported)
- Only supports TCP connections (UDP is not supported)
- Some programs that use special network libraries may be incompatible
Claude automation rules
Rule 1: Automatic retry on network errors
IF 命令返回网络相关错误(timeout, connection refused, DNS failure)
THEN 自动使用 proxychains4 重试该命令
Rule 2: Force proxy for known slow sources
IF 访问以下域名/服务:
- github.com
- raw.githubusercontent.com
- pypi.org
- npmjs.org
- registry.npmjs.org
- docker.io
- gcr.io
THEN 直接使用 proxychains4(不等待失败)
Rule 3: Failure notification
IF proxychains4 命令也失败
THEN 提示用户:
1. 检查代理服务是否运行(127.0.0.1:9910)
2. 检查 proxychains 配置文件
3. 尝试其他代理地址
Troubleshooting
Check proxy service status
# 测试代理是否可用
curl -x http://127.0.0.1:9910 https://www.google.com
# 检查端口是否监听
netstat -tunlp | grep 9910
# 或
ss -tunlp | grep 9910
Verify proxychains configuration
# 测试配置是否正确
proxychains4 curl https://ipinfo.io/json
# 应该显示代理服务器的 IP,而不是本机 IP
Common error handling
Error 1: "proxychains: command not found"
# 安装 proxychains4
sudo apt install proxychains4 # Debian/Ubuntu
sudo yum install proxychains-ng # CentOS/RHEL
Error 2: "timeout"
# 检查代理地址配置是否正确
cat ~/.proxychains/proxychains.conf | grep -A 2 "\[ProxyList\]"
# 修改超时时间(在配置文件中)
tcp_connect_time_out 15000
tcp_read_time_out 30000
Error 3: "can't read configuration file"
# 创建配置文件
mkdir -p ~/.proxychains
cp /etc/proxychains.conf ~/.proxychains/proxychains.conf
# 然后编辑配置
Advanced usage
Multiple proxy chains
# ~/.proxychains/proxychains.conf
strict_chain # 按顺序使用所有代理
[ProxyList]
http 127.0.0.1 9910
socks5 127.0.0.1 1080
Dynamic proxy chains
dynamic_chain # 自动跳过死代理
[ProxyList]
http 127.0.0.1 9910
http 127.0.0.1 8080
socks5 127.0.0.1 1080
Random proxy chains
random_chain
chain_len = 2 # 随机选择 2 个代理
[ProxyList]
http 127.0.0.1 9910
socks5 127.0.0.1 1080
socks5 127.0.0.1 1081
Custom DNS servers
# 使用自定义 DNS 通过代理解析
export PROXY_DNS_SERVER=8.8.8.8
proxychains4 curl https://example.com
Reference resources
- Official repository: https://github.com/haad/proxychains
- Configuration file:
references/proxychains.conf(complete example) - Troubleshooting:
references/troubleshooting.md - Command quick reference:
references/quick-reference.md
Summary
Remember these principles:
- ❌ Encounter a network error → ✅ Automatically add
proxychains4 - 🌐 Access foreign resources → ✅ Actively use
proxychains4 - 🔧 Proxy also fails → ✅ Prompt the user to check the proxy service
Default proxy: http://127.0.0.1:9910
This skill lets Claude automatically use a proxy when encountering network problems, without requiring manual user intervention!