I have multiple Windows-intergated L2TP VPN connections on my server. By default, all internet traffic should be routed through my local network adapter and not through the VPN. My application should be able to select the VPN interface to use for specific web requests. Thus, I want to decide that a specific web request is routed through a special VPN adapter. However, I cannot hard-code routes (using "route add"), because the application should determine this.
I have disabled the option "Use default gateway on remote network", so no traffic will be routed through the VPNs by default.
I have tried to use
BindIPEndPointDelegate to bind to my VPN interface
10.0.0.13, however then I get a
WebException: "Unable to connect to the remote server"
var req = (HttpWebRequest)WebRequest.Create("http://checkip.dyndns.org"); req.ServicePoint.BindIPEndPointDelegate = (servicePoint, remoteEndPoint, retryCount) => new IPEndPoint(IPAddress.Parse("10.0.0.13"), 80); var webResponse = req.GetResponse(); Console.WriteLine(webResponse.ResponseUri); var sr = new StreamReader(webResponse.GetResponseStream()); var readToEnd = sr.ReadToEnd(); Console.WriteLine(readToEnd);
Is there any other way to accomplish this?