温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

redsocks2 自动代理设置

发布时间:2020-05-20 10:59:34 来源:网络 阅读:12711 作者:nonono11 栏目:网络安全

redsock2 可以把一些不支持透明代理的代理服务器重定向一下,这样可以实现透明代理了


redsock2安装很简单直接make就可以了,

ubuntu需要 

apt-get intsll libevent-2.0-5 libssl-dev

安装完成后,直接把 redsocks2 复制到相关目录即可。


我这用它做网关, 然后测试了一下,http 和 https 不能一起走,要分开

redsocks2 配置文件:

base {
  log_debug = off; 
  log_info = off;
  daemon = on;
  redirector= iptables;
}

redsocks {
 local_ip = 192.168.1.1;
 local_port = 1080;
 ip = 192.168.1.1;
 port = 8787;
 type = http-relay;
 timeout = 12;
 autoproxy = 1;
}

redsocks {
 local_ip = 192.168.1.1;
 local_port = 1081;
 ip = 192.168.1.1;
 port = 8787;
 type = http-connect;
 timeout = 12;
 autoproxy = 1;
}

redsocks {
 local_ip = 192.168.1.1;
 local_port = 1090;
 interface = eth0;
 type = direct;    #主要用来解决NAT问题,让WAN可以访问到LAN
 timeout = 1;
 autoproxy = 0;
}

autoproxy {
 no_quick_check_seconds = 300;
 quick_connect_timeout = 2;
}

ipcache {
 cache_size = 4;
 cache_file = "/home/user/conf/cache.ip";
 stale_time = 7200;
 autosave_interval = 3600;
 port_check = 1;
}

相关iptables 设置

#!/bin/bash

iptables-restore</etc/network/iptables.up.rules

iptables -t nat -N RSHTTPS
iptables -t nat -A RSHTTPS -o lo -j RETURN
iptables -t nat -A RSHTTPS -d 0.0.0.0/8 -j RETURN
iptables -t nat -A RSHTTPS -d 10.0.0.0/8 -j RETURN
iptables -t nat -A RSHTTPS -d 127.0.0.0/8 -j RETURN
iptables -t nat -A RSHTTPS -d 169.254.0.0/16 -j RETURN
iptables -t nat -A RSHTTPS -d 172.16.0.0/12 -j RETURN
iptables -t nat -A RSHTTPS -d 172.17.0.0/12 -j RETURN
iptables -t nat -A RSHTTPS -d 192.168.0.0/16 -j RETURN
iptables -t nat -A RSHTTPS -d 224.0.0.0/4 -j RETURN
iptables -t nat -A RSHTTPS -d 240.0.0.0/4 -j RETURN
iptables -t nat -A RSHTTPS -p tcp -j REDIRECT --to-port 1081
iptables -t nat -I PREROUTING -p tcp --dport 443 -j RSHTTPS

iptables -t nat -N RSHTTP
iptables -t nat -A RSHTTP -o lo -j RETURN
iptables -t nat -A RSHTTP -d 0.0.0.0/8 -j RETURN
iptables -t nat -A RSHTTP -d 10.0.0.0/8 -j RETURN
iptables -t nat -A RSHTTP -d 127.0.0.0/8 -j RETURN
iptables -t nat -A RSHTTP -d 169.254.0.0/16 -j RETURN
iptables -t nat -A RSHTTP -d 172.16.0.0/12 -j RETURN
iptables -t nat -A RSHTTP -d 172.17.0.0/12 -j RETURN
iptables -t nat -A RSHTTP -d 192.168.0.0/16 -j RETURN
iptables -t nat -A RSHTTP -d 224.0.0.0/4 -j RETURN
iptables -t nat -A RSHTTP -d 240.0.0.0/4 -j RETURN
iptables -t nat -A RSHTTP -p tcp -j REDIRECT --to-port 1080
iptables -t nat -I PREROUTING -p tcp --dport 80 -j RSHTTP

iptables -t nat -N RSDIRECT
iptables -t nat -A RSDIRECT -p tcp -j REDIRECT --to-port 1090
iptables -t nat -I PREROUTING -p tcp -d 208.67.220.220 -j RSDIRECT
#不加下面这条,没办法WAN网连接进来
iptables -t nat -I PREROUTING -p tcp -s 192.168.1.2 --sport 3389 -j RSDIRECT


pkill redsocks2
redsocks2 -c /home/tool/conf/red.conf


还有另一个叫 cow 的软件也可以实现类似效果。功能上更加强点。

链接地址


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI