Untitled

 avatar
user_7886519
plain_text
a year ago
3.4 kB
10
Indexable
比如我有 3个 socks5 代理,然后我又有 3个 docker ,我想用 xray + iptables 来实现,一直搞不掂
一、docker 已经建了一个独立的网桥了,是 172.18 段的

docker network create --subnet=172.18.0.0/16 test


二、socks5 代理如下
socks5://51.75.125.208:11686
socks5://94.131.107.45:1080
socks5://207.180.226.58:62978

三、iptables 的规则如下
iptables -t nat -A PREROUTING -s 172.18.0.1 -p tcp -j RETURN
iptables -t nat -A PREROUTING -s 172.18.0.0/16 -p tcp -j DNAT --to-destination 172.18.0.1:8765

四、xray 我的配置是
{
    "log": {
        "access": "/dev/null",
        "error": "/dev/null",
        "loglevel": "none"
    },
    "inbounds": [
        {
            "listen": "172.18.0.1",
            "port": 8765,
            "protocol": "dokodemo-door",
            "settings": {
                "network": "tcp,udp",
                "followRedirect": true
            },
            "sniffing": {
                "enabled": true,
                "destOverride": [
                    "http",
                    "tls"
                ]
            }
        }
    ],
    "outbounds": [
        {
            "tag": "socks5_1",
            "protocol": "socks",
            "settings": {
                "servers": [
                    {
                        "address": "207.180.226.58",
                        "port": 62978,
                        "users": [
                            {
                                "user": "",
                                "pass": ""
                            }
                        ]
                    }
                ]
            }
        },
        {
            "tag": "socks5_2",
            "protocol": "socks",
            "settings": {
                "servers": [
                    {
                        "address": "51.75.125.208",
                        "port": 11686,
                        "users": [
                            {
                                "user": "",
                                "pass": ""
                            }
                        ]
                    }
                ]
            }
        },
        {
            "tag": "socks5_3",
            "protocol": "socks",
            "settings": {
                "servers": [
                    {
                        "address": "94.131.107.45",
                        "port": 1080,
                        "users": [
                            {
                                "user": "",
                                "pass": ""
                            }
                        ]
                    }
                ]
            }
        }
    ],
    "routing": {
        "rules": [
            {
                "type": "field",
                "outboundTag": "socks5_1",
                "source": [
                    "172.18.0.2"
                ]
            },
            {
                "type": "field",
                "outboundTag": "socks5_2",
                "source": [
                    "172.18.0.3"
                ]
            },
            {
                "type": "field",
                "outboundTag": "socks5_3",
                "source": [
                    "172.18.0.4"
                ]
            },
            {
                "type": "field",
                "network": "tcp,udp",
                "outboundTag": "direct"
            }
        ]
    }
}
Leave a Comment