Proxy 创建默认网关可以路由&;将所有流量转发到其他socks代理服务器

Proxy 创建默认网关可以路由&;将所有流量转发到其他socks代理服务器,proxy,iptables,gateway,Proxy,Iptables,Gateway,创建一个默认网关,可以将流量路由并转发到socks代理服务器 嗨,我有: 1服务插座5代理位于:1.1.1.1:2 1服务器IP 1.1.1.222希望成为LAN 1.1.1.0/24的默认网关 1客户端1.1.1.x/24使用1.1.1.222作为其默认网关 我想当客户端1.1.1.x检查其IP地址时,它将显示socks5代理服务器的真实IP(默认网关将所有流量路由到该socks服务器) 我一直在寻找这个,得到了类似于redsock+iptables的东西,但没有成功地配置Centos 7。

创建一个默认网关,可以将流量路由并转发到socks代理服务器

嗨,我有:

1服务插座5代理位于:1.1.1.1:2

1服务器IP 1.1.1.222希望成为LAN 1.1.1.0/24的默认网关

1客户端1.1.1.x/24使用1.1.1.222作为其默认网关


我想当客户端1.1.1.x检查其IP地址时,它将显示socks5代理服务器的真实IP(默认网关将所有流量路由到该socks服务器)

我一直在寻找这个,得到了类似于redsock+iptables的东西,但没有成功地配置Centos 7。有人有解决办法吗?谢谢你

###################################
yum install -y libevent-devel git gcc
mkdir ~/shadowsocks
cd ~/shadowsocks
git clone https://github.com/darkk/redsocks
cd ~/shadowsocks/redsocks
make
cp ~/shadowsocks/redsocks/redsocks /usr/local/bin/ 

###################################
nano /root/redsocks.conf
base {
        log_debug = off;
        log_info = on;
        log = stderr;
        daemon = off;
        redirector = iptables;
}
redsocks {
    /* `local_ip' defaults to 127.0.0.1 for security reasons,
     * use 0.0.0.0 if you want to listen on every interface.
     * `local_*' are used as port to redirect to.
     */
    local_ip = 127.0.0.1;
    local_port = 12345;

    // `ip' and `port' are IP and tcp-port of proxy-server
    ip = 1.1.1.1;
    port = 2;

    // known types: socks4, socks5, http-connect, http-relay
    type = socks5;

    // login = "foobar";
    // password = "baz";
}
###################################


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


###################################


sysctl -w net.ipv4.conf.all.forwarding=1
iptables -t nat -N REDSOCKS
iptables -t nat -A PREROUTING -i ens37 -p tcp -j REDSOCKS
iptables -t nat -A PREROUTING -i ens37 -p udp -j REDSOCKS

iptables -A INPUT -i ens37 -p tcp --dport 12345 -j ACCEPT

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-port 12345
iptables -t nat -A REDSOCKS -p udp -j REDIRECT --to-port 12345

###################################