背景

  • 在国内的服务器上从github上拉代码或者go get的时候非常慢(网络受阻)的时候。
  • 当内网的某些服务器不能上外网,但是内网中有一台电脑能上外网,想让不能上外网的服务器上外网的时候。

proxychains可以非常简单快速的设置好代理,让其它不能上网的服务器通过能上网的服务器进行上网。

下载地址

https://github.com/rofl0r/proxychains-ng

安装方法

1 拉取代码

git clone git@github.com:rofl0r/proxychains-ng.git

2 编译安装

[root@localhost proxychains-ng]# cd proxychains-ng
[root@localhost proxychains-ng]# ./configure
[root@localhost proxychains-ng]# make
[root@localhost proxychains-ng]# make install
[root@localhost proxychains-ng]# cp src/proxychains.conf /usr/local/etc/

3 修改配置文件

[root@localhost proxychains-ng]# vi /usr/local/etc/proxychains.conf
#修改最后ProxyList里面的参数,假如我的代理地址为socks5:192.168.137.130 1080
#将socks4 127.0.0.1 9095改为
socks5         192.168.137.130 1080
#如果是http代理,则把socks5改成http

4 使用方法

在需要进行代理的命令前加proxychains即可,如:

#直接访问网络不通的网址
[root@localhost]# curl http://ifconfig.me
curl: (6) Couldn't resolve host 'ifconfig.me'
#使用代理的方式访问
[root@localhost]# proxychains curl http://ifconfig.me
[proxychains] config file found: /usr/local/etc/proxychains.conf
[proxychains] preloading /usr/local/lib/libproxychains4.so
[proxychains] DLL init
[proxychains] Strict chain ... 192.168.137.130:1080 ... ifconfig.me:80 ... OK
119.44.127.54

使用curl、yum、git clone、go get等命令的时候,都只要在前面加上proxychains,就都可以通过192.168.137.130的网络进行访问。