当 JMX 客户端连接时,启用 JMX 的 Java 应用程序似乎打开随机高阶端口
当 JMX 客户端连接时,启用 JMX 的 Java 应用程序似乎打开一个随机高阶端口
我已成功配置了启用 JMX 的 helloworld 程序,并且我可以使用 jconsole JMX 客户端从远程位置连接到它。
当我尝试打开 iptables 时,我注意到客户端登录时会建立一个随机高阶端口。最终我想在防火墙隔离的网段中监视 Java 应用程序。我们可以控制随机端口打开的范围吗?
如果有建议,我会将这个问题移至 serverfault.com。
JMX enabled Java application appears to open a random high order port when JMX client connects
I have successfully configured a helloworld JMX enabled program, and I can connect to it using jconsole JMX client from a remote location.
When I attempt to turn on iptables I noticed that a random high order port is established when a client logs in. Eventually I would like to monitor Java applications in firewall segregated network segments. Can we control the range the random port opens in?
I'll move this question to serverfault.com if suggested.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
从 Java 7u25 开始,可以使用系统属性更改 RMI 端口:
有关详细信息,请参阅此答案。
Since Java 7u25 the RMI port can be changed with a system property:
See this answer for details.
可以控制 RMI 使用的端口。请参阅:http://olegz.wordpress.com/ 2009/03/23/jmx-connectivity-through-the-firewall/
这需要代码和命令行参数。据我所知,没有代码就无法做到这一点(尽管代码显然可以打包在不同的 jar 中)。
It's possible to control the port used by RMI. See: http://olegz.wordpress.com/2009/03/23/jmx-connectivity-through-the-firewall/
This requires code and a command-line parameter. There's no way that I know of to do this without code (though the code can obviously be packaged in a different jar).
随机第三个端口似乎是预期行为 https://bugs.openjdk.java.net/browse /JDK-8035404
Random third port seems to be expected behavior https://bugs.openjdk.java.net/browse/JDK-8035404
顺便说一句,这第三个临时端口也可以控制 - https://www.paybackblog.de/java-jmx-how-to-finally-control-your-ports/
by the way, this third ephemeral port can be controlled too - https://www.paybackblog.de/java-jmx-how-to-finally-control-your-ports/
解决方法是将 RMI 端口设置为与 JMX 端口相同;那么只需要在防火墙上打开一个端口。
例如:
请参阅 为什么 Java 在以下情况下打开 3 个端口JMX配置了吗?
A workaround is to set the RMI port the same as the JMX port; then only that one port needs to be open on the Firewall.
For example:
See Why Java opens 3 ports when JMX is configured?