本文仅限技术交流使用,请勿用于违法用途。 
废话不多说,教程开始! 
安装Redsocks部分
1.安装Redsocks
apt-get install redsocks
2.新建文件 redsocks.conf.example,内容如下请根据实际更改
base {
log_debug = off;
log_info = on;
log = "file:/tmp/redsocks.log";
daemon = on;
redirector = iptables;
}
redsocks {
local_ip = 127.0.0.1;
local_port = 31338;
ip = 127.0.0.1;//转发到的服务器地址和端口,请自行搭建
port = 8888;
type = http;
}
3.拷贝一份配置文件模板并挪到标准路径下:
cp redsocks.conf.example /etc/redsocks.conf
4.加载新的配置文件
/usr/bin/redsocks -c /etc/redsocks.conf
或
service restart redsocks
5.通过netstat查看是否运行正常(监听在31338端口):

iptables部分
# Create new chain
iptables -t nat -N REDSOCKS
# Ignore LANs and some other reserved addresses.
iptables -t nat -A REDSOCKS -d 转发的服务器IP地址 -j RETURN
iptables -t nat -A REDSOCKS -d 0.0.0.0/8 -j RETURN
iptables -t nat -A REDSOCKS -d 10.0.0.0/8 -j RETURN
iptables -t nat -A REDSOCKS -d 127.0.0.0/8 -j RETURN
iptables -t nat -A REDSOCKS -d 169.254.0.0/16 -j RETURN
iptables -t nat -A REDSOCKS -d 172.16.0.0/12 -j RETURN
iptables -t nat -A REDSOCKS -d 192.168.0.0/16 -j RETURN
iptables -t nat -A REDSOCKS -d 224.0.0.0/4 -j RETURN
iptables -t nat -A REDSOCKS -d 240.0.0.0/4 -j RETURN
iptables -t nat -A REDSOCKS -p tcp -j REDIRECT --to-ports 31338(转发的服务器端口)
iptables -t nat -A OUTPUT -p tcp -j REDSOCKS
iptables -t nat -A PREROUTING -p tcp -j REDSOCKS
成果检验
root@Redsocks:~# curl https://www.cip.cc/
IP : 1.1.1.1
地址 : 中国 北京
运营商 : beijing.com
数据二 : 中国北京市 | BGP高防数据中心
数据三 : 中国北京市 | 电信
URL : http://www.cip.cc/1.1.1.1






ns有你更精彩
收藏了~
不知道具体用途,感觉挺厉害,先收藏了