机器上有很多ip地址,设置传出ip java [英] many ip addresses on machine, set outgoing ip java
问题描述
我最近有一台拥有10个IPv6地址的机器,这是运行MySQL和tomcat的CentOS,我使用spring来创建servlet。
I recently got a machine with 10 IPv6 addresses, this is a CentOS running MySQL and tomcat, I'm using spring to create servlets.
我想知道的是有一种Java方式(不是操作系统路由表)来设置我的服务器上可用的传出IP吗?
I was wondering is there a Java way (not OS routing tables) to set the outgoing IP from the ones available on my server?
我想要做的是传入地址到达servlet并相应地从特定的IP做一个http帖子。
What I am trying to do is have a incoming address reach the servlets and do an http post from a specific IP accordingly.
对于我所有的研究,我看到最接近解决这个问题的是httplib,但有这样的东西吗for Java?
For all my research the thing I saw closest to solving this would be httplib, but is there something like this for Java?
推荐答案
只需在套接字中使用localaddr参数。
just use localaddr parameter in your socket.
非常重复的问题这里:
这篇关于机器上有很多ip地址,设置传出ip java的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!