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 對應程式