通过 VPN 拆分隧道与远程服务器的 TCP 连接

问题描述 投票:0回答:0

我正在尝试通过活动的 VPN 拆分隧道与远程服务器创建 TCP 连接

到目前为止,我已经尝试使用 2 种方法来实现这一目标。

第一种方法是将 TCP 客户端绑定到本地端点,即 VPN 隧道。

            string VPN_IP = "10.0.4.2";
            var VPN_Tunnel = new IPEndPoint(IPAddress.Parse(VPN_IP), 0);
            TcpClient tcp = new TcpClient(VPN_Tunnel); //Bind tcp to local endpoint

            string remoteIP = "108.12.18.118"; // Example remote server
            int port = 9999; // ex. specific port
            tcp.BeginConnect(remoteIP, port, ConnectCallback, null);

            // Write some bytes to NetworkStream
            stream.BeginWrite(bytes, 0, bytes.Length, WriteCallback, null);

第二种方法是创建一个不绑定到本地端点的 TCP 客户端。

但是,在常规 TCP 连接之前,我发送路由命令

route -p add 108.12.18.118 mask 255.255.255.255 10.0.4.2

两种方法都行不通

c# .net routes vpn tcpclient
© www.soinside.com 2019 - 2024. All rights reserved.