Skip to content
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

向redis注册服务的时候,获取service提供者的ip时,在windows系统上获取的ip不正确 #4

Open
agilesw opened this issue Oct 24, 2018 · 0 comments

Comments

@agilesw
Copy link
Contributor

agilesw commented Oct 24, 2018

s/Server.go
通过addrs, _ := net.InterfaceAddrs()获取的ip为:addrs, _ := net.InterfaceAddrs()
得到结果:
[fe80::150d:b4b3:cf2c:2d02/64 169.254.45.2/16 192.168.137.1/24 fe80::fd3d:1ddd:40b2:f6fc/64 169.254.246.252/16 fe80::a4cf:b26f:e2ec:3c15/64 169.254.60.21/16 fe80::7982:86dd:4f4:c5b4/64 10.59.6.79/20 fe80::a925:65ee:23ec:24
9a/64 10.51.12.165/24 ::1/128 127.0.0.1/8 fe80::5efe:a33:ca5/128]
通过以下代码段获取到ip地址:
if an.IP.IsGlobalUnicast() && !strings.HasPrefix(an.IP.To4().String(), "172.17.") {
ip = an.IP.To4()
break
}
得到192.168.137.1,这个ip提供的server是无法访问的
实际可用的ip 10.51.12.165

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant