| name | proxychains |
| description | Auto-detect network issues and force proxy usage with proxychains4. Use this skill when encountering connection timeouts, DNS failures, or blocked network access. Default proxy is http://127.0.0.1:9910 |
Proxychains Network Proxy Skill
自動使用代理解決網路問題 - 當遇到網路連線失敗、超時或訪問受限時,自動使用 proxychains4 強制走代理。
When to Use This Skill
觸發條件(自動應用):
- ❌ Connection timeout errors
- ❌ DNS resolution failures
- ❌ "Connection refused" errors
- ❌ HTTP 403/451 blocked access
- ❌ GitHub/PyPI/npm 等國外資源訪問失敗
- ❌ curl/wget/git/pip 等命令失敗
Claude 應該:
- 檢測到網路錯誤後,自動在命令前新增
proxychains4
- 使用預設代理配置:
http://127.0.0.1:9910
- 如果代理失敗,提示使用者檢查代理服務狀態
Quick Reference
基本用法模式
curl https://github.com/user/repo
proxychains4 curl https://github.com/user/repo
常見場景自動應用
場景 1: Git 操作失敗
git clone https://github.com/user/repo.git
proxychains4 git clone https://github.com/user/repo.git
場景 2: Python pip 安裝失敗
pip install requests
proxychains4 pip install requests
場景 3: npm/yarn 安裝失敗
npm install package-name
proxychains4 npm install package-name
場景 4: wget/curl 下載失敗
wget https://example.com/file.tar.gz
proxychains4 wget https://example.com/file.tar.gz
場景 5: Docker 拉取映象失敗
docker pull image:tag
proxychains4 docker pull image:tag
場景 6: SSH 連線失敗
ssh user@remote-host
proxychains4 ssh user@remote-host
配置詳情
預設代理配置
本地代理地址: http://127.0.0.1:9910
配置檔案位置:
~/.proxychains/proxychains.conf (推薦)
/etc/proxychains.conf (系統級)
快速配置指令碼
建立使用者級配置(自動使用 127.0.0.1:9910):
mkdir -p ~/.proxychains
cat > ~/.proxychains/proxychains.conf << 'EOF'
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
環境變數方式(臨時使用)
export PROXYCHAINS_SOCKS5_HOST=127.0.0.1
export PROXYCHAINS_SOCKS5_PORT=9910
proxychains4 curl https://github.com
工作原理
Proxychains 透過 LD_PRELOAD 機制攔截程式的網路呼叫:
- 攔截系統呼叫:Hook socket 相關的 libc 函式
- 重定向連線:將所有 TCP 連線重定向到代理伺服器
- DNS 代理:透過代理伺服器解析域名
- 透明代理:應用程式無需修改
重要限制:
- 只支援動態連結的程式(statically linked 程式不支援)
- 只支援 TCP 連線(UDP 不支援)
- 部分使用特殊網路庫的程式可能不相容
Claude 自動化規則
規則 1: 網路錯誤自動重試
IF 命令返回網路相關錯誤(timeout, connection refused, DNS failure)
THEN 自動使用 proxychains4 重試該命令
規則 2: 已知慢速源強制代理
IF 訪問以下域名/服務:
- github.com
- raw.githubusercontent.com
- pypi.org
- npmjs.org
- registry.npmjs.org
- docker.io
- gcr.io
THEN 直接使用 proxychains4(不等待失敗)
規則 3: 失敗提示
IF proxychains4 命令也失敗
THEN 提示使用者:
1. 檢查代理服務是否執行(127.0.0.1:9910)
2. 檢查 proxychains 配置檔案
3. 嘗試其他代理地址
故障排除
檢查代理服務狀態
curl -x http://127.0.0.1:9910 https://www.google.com
netstat -tunlp | grep 9910
ss -tunlp | grep 9910
驗證 proxychains 配置
proxychains4 curl https://ipinfo.io/json
常見錯誤處理
錯誤 1: "proxychains: command not found"
sudo apt install proxychains4
sudo yum install proxychains-ng
錯誤 2: "timeout"
cat ~/.proxychains/proxychains.conf | grep -A 2 "\[ProxyList\]"
tcp_connect_time_out 15000
tcp_read_time_out 30000
錯誤 3: "can't read configuration file"
mkdir -p ~/.proxychains
cp /etc/proxychains.conf ~/.proxychains/proxychains.conf
高階用法
多代理鏈
# ~/.proxychains/proxychains.conf
strict_chain # 按順序使用所有代理
[ProxyList]
http 127.0.0.1 9910
socks5 127.0.0.1 1080
動態代理鏈
dynamic_chain # 自動跳過死代理
[ProxyList]
http 127.0.0.1 9910
http 127.0.0.1 8080
socks5 127.0.0.1 1080
隨機代理鏈
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
自定義 DNS 伺服器
export PROXY_DNS_SERVER=8.8.8.8
proxychains4 curl https://example.com
參考資源
總結
記住這些原則:
- ❌ 遇到網路錯誤 → ✅ 自動加上
proxychains4
- 🌐 訪問國外資源 → ✅ 主動使用
proxychains4
- 🔧 代理也失敗 → ✅ 提示使用者檢查代理服務
預設代理: http://127.0.0.1:9910
這個技能讓 Claude 在遇到網路問題時自動使用代理,無需使用者手動干預!