通过 WinSocks 或任何其他 API 进行应用程序的特殊路由?
我想将从我的应用程序发送的数据包路由到另一个网关,但我不知道必须通过setsockopt 更改哪些选项。 我不能只向特定主机的路由表添加条目,因为第二个应用程序也必须通过默认网关连接到这些主机。网关有不同的公共IP。 我找到了有关通过 IP_OPTIONS 套接字选项设置“源路由”选项的主题(尽管没有格式),但据我了解,此选项仅适用于路由器而不适用于我的网络适配器。 我也无法添加第二个适配器并将其连接到同一局域网。
有什么建议我可以如何根据每个应用程序发送数据包?可能是路由 API
P.S.:Windows 版本为 32 位 XP SP3、32 位和 64 位 Windows 7 以及 1 个 64 位 Windows Server 2008 R2。
I want to route packets sended from my application to another gateway but i don't know what options i must change via setsockopt.
I can't just add entries to routing table for specific hosts because second application also must connect to these hosts but via default gateway. Gateways have different public IPs.
I found topic about set "source routing" options via IP_OPTIONS socket option (though without format), but as i understand this option only for routers not for my network adapter.
Also i cannot add second adapter and connect it to same LAN.
Any suggestions how i can send packets on per application basis? May be routing API
P.S.: Windows versions are 32-bit XP SP3, 32- and 64 bit Windows 7 and one 64-bit Windows Server 2008 R2.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
简短的回答:这真的很难,你确定要这样做吗?直接通过 set sock opt 是不可能的。通过使用命令行实用程序“route”手动添加路由,很可能有更简单的选择。如果您的最终目的地是已知的 IP 或网络并且正常流量也可以通过其他网关路由,那么这将是最佳选择。
更长的答案:如果您是代码忍者,您有以下两个选择,祝您好运,我不知道这在实践中是否有效:
Short answer : this is really hard, are you sure you want to do it ? It is not possible directly via set sock opt. Most probably there are easier choices by adding routes manually with the command line utility "route". That will the best choice if your final destination is a known IP or network and that normal traffic can be routed through the other gateway as well.
Longer answer : if you are a code ninja, you have the following two options, good luck, I have no idea whether that will work in practice: