赞
踩
每次访问时都需要写代理参数
curl -x socks5://127.0.0.1:1024 http://www.google.com # -x 参数等同于 --proxy
每次使用curl
的时候都会使用代理
- # 修改curl配置文件
- vim ~/.curlrc
- # 写入
- socks5 = "127.0.0.1:1024"
-
- # 如果临时不需要代理使用以下参数
- curl --noproxy "*" http://www.google.com
不仅仅适用于curl
,大部分的linux命令行工具都会读取这个配置通过代理访问网络。
- # 修改shell配置文件 ~/.bashrc ~/.zshrc等
- export http_proxy=socks5://127.0.0.1:1024
- export https_proxy=$http_proxy
-
- # 设置setproxy和unsetproxy 可以快捷的开关
- # 需要时先输入命令 setproxy
- # 不需要时输入命令 unsetproxy
- alias setproxy="export http_proxy=socks5://127.0.0.1:1024; export https_proxy=$http_proxy; echo 'HTTP Proxy on';"
- alias unsetproxy="unset http_proxy; unset https_proxy; echo 'HTTP Proxy off';"
curl -v
参数会输出请求中访问的路由信息,方便确定是否设置成功,请求有没有代理netstat -nat | grep 1024
查看与代理端口相链接的端口lsof -i :1024
查看端口相关的进程Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。