码迷,mamicode.com
首页 > 其他好文 > 详细

redsocks 设置全局代理

时间:2015-05-04 23:48:28      阅读:488      评论:0      收藏:0      [点我收藏+]

标签:

分享一下我的经验,

 http://lilydjwg.is-programmer.com/2014/2/7/linux-really-global-http-proxy.42701.html

 

1. 优点: 设置一次,全局代理。连虚拟机都不要设置代理。

2. 缺点: 会停止工作,我把它放到crontab里。

 

1. 编译redsocks https://github.com/darkk/redsocks.

 

2. proxy.sh

 

iptables -t nat -N REDSOCKS || true

iptables -t nat -F REDSOCKS

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 6666

iptables -t nat -A REDSOCKS -p udp -j REDIRECT --to-ports 8888

iptables -t nat -A OUTPUT -p tcp -j REDSOCKS

pkill redsocks

/root/bin/redsocks -c /root/bin/redsocks.conf

 

3. redsocks.conf

 

base {

log_debug = on;

log_info = on;

daemon = on;

redirector = iptables;

}

 

redsocks {

local_ip = 127.0.0.1;

local_port = 6666;

ip = 10.102.248.16; <---- proxy server IP.

port = 1080;

type = socks5;

}

redudp {

local_ip = 127.0.0.1;

local_port = 8888;

ip = 10.102.248.16;

port = 1080;

}

dnstc {

local_ip = 127.0.0.1;

local_port = 5300;

redsocks 设置全局代理

标签:

原文地址:http://www.cnblogs.com/shaohef/p/4477862.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!