V2ray-core: inbound detour和outbound detour可以实现指定多对多的关系吗

Created on 30 Jul 2017  ·  8Comments  ·  Source: v2ray/v2ray-core

比如inbound 1进就从outbound 1出,
inbound 2进就从outbound 2出,
类似这样的

Most helpful comment

{
  "port": 1111,
  "inbound": {
    "protocol": "socks", // 入口协议为 SOCKS 5
    "settings": {
      "auth": "noauth",  // 不认证
      "udp": false       // 不开启 UDP 转发
    }
   },
  "inboundDetour": [
    {
      "protocol": "http",
      "port": 2222,
      "settings": {
        "auth": "noauth",
        "udp": false
      }
    },
    {
      "protocol": "http",
      "port": 3333,
      "tag": "tag-in-vmess",
      "settings": {
        "auth": "noauth",
        "udp": false
      }
    }
  ],
  "outbound": {
    "protocol": "vmess", // 出口协议
    "settings": {
      "vnext": [
        {
          "address": "sever1ip", // 服务器 IP 地址
          "port": 4444,  // 服务器端口
          "users": [
            {"id": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"} // 用户 ID,须与服务器端配置相同
          ]
        }
      ]
    }
  },
  "outboundDetour": [
    {
      "protocol": "freedom", // 额外的出口协议。Freedom 协议为直连模式,不经过服务器中转。
      "settings": {},
      "tag": "direct"  // 标签,在路由中用到
    },
    {
      "protocol": "vmess", // 出口协议
      "tag": "s2-vmess",
      "settings": {
        "vnext": [
          {
            "address": "sever2ip", // 服务器 IP 地址
            "port": 5555,  // 服务器端口
            "users": [
              {
                "id": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", // 用户 ID,须与服务器端配置相同
                "alterId": 10,
                "security": "aes-128-cfb"
              }
            ]
          }
        ]
      }
    }
  ],
  "routing": {
    "strategy": "rules",
    "settings": {
      "rules": [
        {
          "type": "field",
          "domain": [
              "google.com"
          ],
          "outboundTag": "default"
        },
        {
          "type": "chinasites",
          "outboundTag": "direct"
        },
        {
          "type": "chinaip",
          "outboundTag": "direct"
        },
        {
          "type": "field",  // 路由设置,默认将屏蔽所有局域网流量,以提升安全性。
          "ip": [
            "0.0.0.0/8",
            "10.0.0.0/8",
            "100.64.0.0/10",
            "127.0.0.0/8",
            "169.254.0.0/16",
            "172.16.0.0/12",
            "192.0.0.0/24",
            "192.0.2.0/24",
            "192.168.0.0/16",
            "198.18.0.0/15",
            "198.51.100.0/24",
            "203.0.113.0/24",
            "::1/128",
            "fc00::/7",
            "fe80::/10"
          ],
          "outboundTag": "blocked"
        },
        {
          "type": "field",
          "inboundTag": [
            "tag-in-vmess"
          ],
          "outboundTag": "s2-vmess"
        }
      ]
    }
  }
}

All 8 comments

@chestermax01 Reply #1

可以,请参考官方文档 路由配置 - v2ray.com

"inboundDetour": [
{
"protocol": "http",
"port": 1234,
"settings": {
"auth": "noauth",
"udp": false
}
},
{
"protocol": "http",
"port": 1235,
"tag": "tag-test-vmess",
"settings": {
"auth": "noauth",
"udp": false
}
}
]

"routing": {
"strategy": "rules",
"settings": {
"rules": [
{
"type": "field",
"domain": [
"google.com"
],
"outboundTag": "default"
},
{
"type": "chinasites",
"outboundTag": "direct"
},
{
"type": "chinaip",
"outboundTag": "direct"
},
{
"type": "field",
"ip": [
"0.0.0.0/8",
"10.0.0.0/8",
"100.64.0.0/10",
"127.0.0.0/8",
"169.254.0.0/16",
"172.16.0.0/12",
"192.0.0.0/24",
"192.0.2.0/24",
"192.168.0.0/16",
"198.18.0.0/15",
"198.51.100.0/24",
"203.0.113.0/24",
"::1/128",
"fc00::/7",
"fe80::/10"
],
"outboundTag": "blocked"
},
{
"type": "field",
"inboundTag": [
"tag-test-vmess"
],
"outboundTag": "test-vmess"
}
]
}
}

inboundDetour和routing元素如上,有没有问题?

"outboundDetour": [
{
"protocol": "freedom",
"settings": {},
"tag": "direct"
},
{
"protocol": "vmess",
"tag": "test-vmess",
"settings": {
"vnext": [
{
"address": "xx.xx.xx.xx",
"port": 9011,
"users": [
{
"id": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
"alterId": 10,
"security": "aes-128-cfb"
}
]
}
]
}
}
],

outboundDetour元素如上

@chestermax01 Reply #3

你直接试一下你的配置文件,能正常使用就不需要发在这里 并且可以直接关闭该 Issue。

不行,失败了,几次打不开网页后转入outbound了

@chestermax01 Reply #5

请把修改后的配置文件完整的贴出来,贴的时候请使用 Markdown 代码块语法

{
  "port": 1111,
  "inbound": {
    "protocol": "socks", // 入口协议为 SOCKS 5
    "settings": {
      "auth": "noauth",  // 不认证
      "udp": false       // 不开启 UDP 转发
    }
   },
  "inboundDetour": [
    {
      "protocol": "http",
      "port": 2222,
      "settings": {
        "auth": "noauth",
        "udp": false
      }
    },
    {
      "protocol": "http",
      "port": 3333,
      "tag": "tag-in-vmess",
      "settings": {
        "auth": "noauth",
        "udp": false
      }
    }
  ],
  "outbound": {
    "protocol": "vmess", // 出口协议
    "settings": {
      "vnext": [
        {
          "address": "sever1ip", // 服务器 IP 地址
          "port": 4444,  // 服务器端口
          "users": [
            {"id": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"} // 用户 ID,须与服务器端配置相同
          ]
        }
      ]
    }
  },
  "outboundDetour": [
    {
      "protocol": "freedom", // 额外的出口协议。Freedom 协议为直连模式,不经过服务器中转。
      "settings": {},
      "tag": "direct"  // 标签,在路由中用到
    },
    {
      "protocol": "vmess", // 出口协议
      "tag": "s2-vmess",
      "settings": {
        "vnext": [
          {
            "address": "sever2ip", // 服务器 IP 地址
            "port": 5555,  // 服务器端口
            "users": [
              {
                "id": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", // 用户 ID,须与服务器端配置相同
                "alterId": 10,
                "security": "aes-128-cfb"
              }
            ]
          }
        ]
      }
    }
  ],
  "routing": {
    "strategy": "rules",
    "settings": {
      "rules": [
        {
          "type": "field",
          "domain": [
              "google.com"
          ],
          "outboundTag": "default"
        },
        {
          "type": "chinasites",
          "outboundTag": "direct"
        },
        {
          "type": "chinaip",
          "outboundTag": "direct"
        },
        {
          "type": "field",  // 路由设置,默认将屏蔽所有局域网流量,以提升安全性。
          "ip": [
            "0.0.0.0/8",
            "10.0.0.0/8",
            "100.64.0.0/10",
            "127.0.0.0/8",
            "169.254.0.0/16",
            "172.16.0.0/12",
            "192.0.0.0/24",
            "192.0.2.0/24",
            "192.168.0.0/16",
            "198.18.0.0/15",
            "198.51.100.0/24",
            "203.0.113.0/24",
            "::1/128",
            "fc00::/7",
            "fe80::/10"
          ],
          "outboundTag": "blocked"
        },
        {
          "type": "field",
          "inboundTag": [
            "tag-in-vmess"
          ],
          "outboundTag": "s2-vmess"
        }
      ]
    }
  }
}

实现了,谢谢

实现了,谢谢

大哥,实现了能不能把配置帖了下,方便后来者...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sunsan05 picture sunsan05  ·  3Comments

ToutyRater picture ToutyRater  ·  4Comments

supersonic600 picture supersonic600  ·  3Comments

nielspeen picture nielspeen  ·  4Comments

pingma picture pingma  ·  4Comments