ubuntu-连接ssr的socks5代理
ubuntu-连接ssr的socks5代理
前篇
所有 命令 连接某个机子上的 ssr 的 socks5 请求外网. 需要用到 proxychains-ng: https://github.com/rofl0r/proxychains-ng.git
前置物料
开启机子A ( 192.168.1.200
) 的 ssr socks5, 端口: 10088
使用流程
参考: ubuntu下安装proxychains - https://blog.csdn.net/lazybones_3/article/details/85129470
下载源码包
1
$ git clone https://github.com/rofl0r/proxychains-ng.git
编译生成
1
2
3
4$ cd proxychains-ng/ // cd 进去编译生成
$ ./configure --prefix=/usr --sysconfdir=/etc
$ make && make install
$ make install-config // 创建配置文件如果命令报错:
make: cc: Command not found
, 需要安装编译工具1
2$ apt install make
$ apt install gcc
修改配置
1
2
3$ vi /etc/proxychains.conf
// 最后一行, 修改 socks4 为目标机子的ssr端口
socks5 192.168.1.200 10088测试一下, 只要命令带上
proxychains4
就可以走代理测试 ping 一下 google
1
2
3
4
5
6
7
8$ proxychains4 ping google.com
[proxychains] config file found: /etc/proxychains.conf
[proxychains] preloading /usr/lib/libproxychains4.so
[proxychains] DLL init: proxychains-ng 4.14-git-8-gb8fa2a7
PING google.com (224.0.0.1) 56(84) bytes of data.
64 bytes from 192.168.1.155 (192.168.1.155): icmp_seq=1 ttl=64 time=0.443 ms // 有回复
64 bytes from 192.168.1.155 (192.168.1.155): icmp_seq=2 ttl=64 time=0.230 ms
64 bytes from 192.168.1.155 (192.168.1.155): icmp_seq=3 ttl=64 time=0.268 ms测试 拉 GitHub 代码
给
proxychains4
加个别名, 方便使用1
2
3
4
5$ vi ~/.bash_profile
alias pc='proxychains4' # 添加别名
$ source ~/.bash_profile // 使其生效done
1
2
3
4
5
6
7root@ubuntu:~# pc ping google.com
[proxychains] config file found: /etc/proxychains.conf
[proxychains] preloading /usr/lib/libproxychains4.so
[proxychains] DLL init: proxychains-ng 4.14-git-8-gb8fa2a7
PING google.com (224.0.0.1) 56(84) bytes of data.
64 bytes from 192.168.1.155 (192.168.1.155): icmp_seq=1 ttl=64 time=0.287 ms
64 bytes from 192.168.1.155 (192.168.1.155): icmp_seq=2 ttl=64 time=0.150 ms
设置所有 http 请求都走代理
添加一个环境变量 ALL_PROXY
即可, 指定 socks 的地址端口
1 | $ export ALL_PROXY=socks5://127.0.0.1:10088 |
然后测试一下
1 | $ curl https://www.google.com |