-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
复杂网络环境下IP地址获取不准确的问题 #1
Labels
Comments
fixed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
问题发生位置
![Uploading 1.jpg…]()
工程:elastic-job-core,类:com.dangdang.ddframe.job.internal.env.RealLocalHostService,方法:getLocalHost().
说明:对于一般性网络环境,代码段:InetAddress.getLocalHost();,可以正确的获取到本机的ip。
对于复杂的企业环境,企业网络管理员可能会进行部门子网、小组子网的划分,并最终链入企业主路由;
这样一台员工主机可能会有多个内网ip,代码段:InetAddress.getLocalHost();默认会返回当前主机链接到最近网络拓扑路径的路由所分配的子网ip。
综上,代码段:InetAddress.getLocalHost();得到的ip可能与实际链接到zookeeper的ip出现不一致。
可以想象的到,错误的将子网路由ip作为链接到zookeeper的ip,会导致同子网下,不同机器链接zookkeeper出现判断错误。
建议修改代码:https://github.com/amao12580/RSSReader/blob/master/core.base/src/main/java/per/rss/core/base/util/IPUtils.java
The text was updated successfully, but these errors were encountered: