Kali Linux 配置系统代理

打开redsocks配置文件

vim /etc/redsocks.conf

修改配置文件

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
        // You can also use hostname instead of IP, only one (random)
        // address of multihomed host will be used.
        ip = 127.0.0.1;
        port = 1080;


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

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

将上面的ipport改成你代理服务的地址和端口,也就是把流量转发到哪里

启动redsocks,这一步每次开机都要弄一次

redsocks
#不重定向目的地址为服务器的包
iptables -t nat -A OUTPUT -d *.*.*.* -j RETURN  #请用你的服务器的地址替换$SERVER_IP
 
#不重定向私有地址的流量
iptables -t nat -A OUTPUT -d 10.0.0.0/8 -j RETURN
iptables -t nat -A OUTPUT -d 172.16.0.0/16 -j RETURN
iptables -t nat -A OUTPUT -d 192.168.0.0/16 -j RETURN
 
#不重定向保留地址的流量,这一步很重要
iptables -t nat -A OUTPUT -d 127.0.0.0/8 -j RETURN
 
#重定向所有不满足以上条件的流量到redsocks监听的12345端口
iptables -t nat -A OUTPUT -p tcp -j REDIRECT --to-ports 12345 #12345是你的redsocks运行的端口,请根据你的情况替换它

请使用你的代理服务的ip地址替换...,然后在命令行执行这些语句

posted @ 2023-07-02 15:54  乘舟凉  阅读(657)  评论(0编辑  收藏  举报