dubbo注册服务IP地址总是127.0.0.1而不是内网地址
Why are the IP addresses obtained by the registered services all 127.0.0.1 instead of the intranet IP? Can I specify to get the intranet address? eho0?
Tell us your environment
dubbo 2.7.1
dubbo-registry-nacos 2.7.1
nacos-client 1.0.0-RC3

Maybe, I also face the same problem
https://github.com/apache/incubator-dubbo/issues/3923
具体的配置文件能否提供一下,我这边测试如下配置<dubbo:protocol name="dubbo"/>,发现注册中心的地址是内网地址。
@boomblog 我用的是nacos注册中心,spring boot 整合dubbo
Spring boot application
dubbo.registry.address=nacos://192.168.1.214:8848 dubbo.protocol.port=-1
对hosts 文件进行配置 1.使用 hostname 命令取得当前的 机器名 2.将机器名和内网 ip 配置进 hosts
对hosts 文件进行配置 1.使用 hostname 命令取得当前的 机器名 2.将机器名和内网 ip 配置进 hosts
没用~试过的
@boomblog 我用的是nacos注册中心,spring boot 整合dubbo
com.alibaba.boot nacos-config-spring-boot-starter 0.2.1
org.apache.dubbo dubbo-registry-nacos 2.7.1
com.alibaba.nacos nacos-client 1.0.0-RC3
org.apache.dubbo dubbo-spring-boot-starter 2.7.1
private String findConfigedHosts(ProtocolConfig protocolConfig, List
String hostToBind = getValueFromConfig(protocolConfig, Constants.DUBBO_IP_TO_BIND);
// if bind ip is not found in environment, keep looking up
if (StringUtils.isEmpty(hostToBind)) {
hostToBind = protocolConfig.getHost();
if (provider != null && StringUtils.isEmpty(hostToBind)) {
hostToBind = provider.getHost();
}
if (StringUtils.isEmpty(hostToBind)) {
anyhost = true;
**hostToBind = getLocalHost();**
if (StringUtils.isEmpty(hostToBind)) {
hostToBind = findHostToBindByConnectRegistries(registryURLs);
}
}
}
map.put(Constants.BIND_IP_KEY, hostToBind);
// registry ip is not used for bind ip by default
String hostToRegistry = getValueFromConfig(protocolConfig, Constants.DUBBO_IP_TO_REGISTRY);
if (StringUtils.isEmpty(hostToRegistry)) {
// bind ip is used as registry ip by default
hostToRegistry = hostToBind;
}
map.put(Constants.ANYHOST_KEY, String.valueOf(anyhost));
return hostToRegistry;
}
这是获取host的源码,你可以先本地测一下调用getLocalHost()这个方法返回的是什么
对hosts 文件进行配置 1.使用 hostname 命令取得当前的 机器名 2.将机器名和内网 ip 配置进 hosts
没用~试过的
不要重复出现 hostname
seam question
这是获取host的源码,你可以先本地测一下调用getLocalHost()这个方法返回的是什么
可以按照这里的步骤尝试先试一下看。
給遇到這個問題的人 我前不久也遇到這個問題
後來發現是我電腦有裝Http Proxy或是VPN的東西 他一直嘗試把我的ip註冊到http proxy的網域
可以用nslookup來查看自己的ip位置是跑到哪裡