Redsocks是一個開源的網絡程序,代碼依賴開源的libevent網絡庫。Redsocks允許你將所有TCP連接重定向到SOCKS或HTTPS代理,比如Shadowsocks(Centos7下安裝配置Shadowsocks)。通常的用途是流量透傳或流量轉發,首先將本機上目的地為的某些特定IP的流量轉發到Redsocks的監聽端口上(本文為8888),之后Redsocks會將這些流量再轉發給后端的Shadowsocks,再通過shadowocks轉到更遠的地方。
1、下載編譯
[root@localhost ~]# yum install libevent-devel git gcc [root@localhost ~]# mkdir ~/shadowsocks [root@localhost ~]# cd ~/shadowsocks [root@localhost ~]# git clone https://github.com/darkk/redsocks [root@localhost ~]# cd ~/shadowsocks/redsocks [root@localhost ~]# make [root@localhost ~]# cp ~/shadowsocks/redsocks/redsocks /usr/local/bin/
2、新建配置文件(默認即可,無需更改)
[root@localhost ~]# vi /etc/redsocks.conf base { log_debug = off; log_info = on; log = stderr; daemon = off; redirector = iptables; } redsocks { local_ip = 127.0.0.1; local_port = 8888; ip = 127.0.0.1; port = 1080; type = socks5; }
3、啟動/停止
啟動 [root@localhost ~]# nohup /usr/local/bin/redsocks -c /etc/redsocks.conf & 停止 [root@localhost ~]# kill -9 對應進程