通过一个网络接口进行 Http 请求
我想仅在选定的网络接口上调用剩余 Web 服务的 HTTP 请求。
任何对此的建议将不胜感激。
I would like to call HTTP request for rest webservice only on selected network interface.
Any advice on this would be much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我发现你可以像这样在 url 中定义网络接口:
它可以在 Ubuntu 中工作,我希望它也可以在不同的系统中工作。
I found out that you can define network interface in url like this :
It's working in Ubuntu and I hope that it works in different systems too.
这或多或少超出了 Java 程序的控制范围。
由操作系统决定将数据包发送到哪里。它将在配置为具有到目标 IP 的路由的接口上发送数据包 - 或在默认路由上发送数据包。因此,您必须确保操作系统已正确配置,以便将 IP 数据包路由到您想要的位置,并且它只会在该接口上发送它们。
This is more or less out of the control of your Java program.
It's up to the OS to decide where to send the packets. It'll send the packets on the interface that's configured to have a route to the destination IP - or send it on the default route. So, you have to just make sure you've configured your OS properly to route the IP packets where you want them, and it'll only send them on that interface.