1. 临时使用 SOCKS5 代理(命令行)
使用 curl 通过 SOCKS5 代理
curl --socks5 127.0.0.1:1080 http://www.example.com curl --socks5-hostname 127.0.0.1:1080 http://www.example.com
使用 wget 通过 SOCKS5 代理
wget -e use_proxy=yes -e socks5_proxy=127.0.0.1:1080 http://www.example.com
2. 环境变量配置(临时会话)
# 设置 SOCKS5 代理 export ALL_PROXY=socks5://127.0.0.1:1080 export SOCKS5_PROXY=127.0.0.1:1080 # 验证代理是否生效 curl http://ipinfo.io/ip # 取消代理设置 unset ALL_PROXY SOCKS5_PROXY
3. 配置系统级代理
方法一:使用 proxychains-ng
- 
安装 proxychains-ng:
 
sudo apt update sudo apt install proxychains4
- 
配置 proxychains:
编辑/etc/proxychains4.conf: 
sudo nano /etc/proxychains4.conf
在文件末尾添加:
socks5 127.0.0.1 1080
- 
使用 proxychains:
 
# 运行任何命令都通过 SOCKS5 代理 proxychains4 curl http://www.example.com proxychains4 apt update proxychains4 wget http://www.example.com
文章评论