Dns.GetHostEntry 返回多个 IP 地址 [英] Dns.GetHostEntry returns multiple IP addresses

查看:31
本文介绍了Dns.GetHostEntry 返回多个 IP 地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题可能突出了我对网络原理的缺乏了解,而不是编程问题.

This question probably highlights a lack of understanding of networking principals on my part, rather than a programming issue.

我正在使用

Dns.GetHostEntry

这会向我返回一个 IPHostEntry,它有一个 AddressList 属性,它是一个 IPAddress 数组.

This returns an IPHostEntry to me, which has an AddressList property which is an array of IPAddress.

我一直认为主机名和 IP 之间存在 1 对 1 的映射,但我发现在某些情况下我会为同一主机取回多个 IP 地址.

I always thought there is a 1 to 1 mapping between hostname and IP, but I'm finding that in some cases I get back several IPAddress(es) for the same host.

这对我来说是一个惊喜.

This is a surprise to me.

我不明白域名解析的哪个部分?

Which part of domain name resolution do I not understand?

推荐答案

任何系统都可以有多个网络接口和 Internet 地址,但只有一个名称.从名称到地址的转发映射将返回映射到特定名称的所有地址.我们过去使用我们的文件服务器来做到这一点,这样主机在访问文件时就不必跨越网络边界,也不必将负载分散到各种 NIC 上.文件服务器将驻留在我们的各个子网中,具有多个接口卡,每个接口卡具有不同的子网地址,但名称相同.校园内的 DNS 服务器仍然是这样设置的.此外,您可能有一个映射到多个系统的名称,通过 DNS 提供某种程度的负载平衡.

Any system can have multiple network interfaces and internet addresses, yet only have one name. The forward mapping from name to address will return all of the addresses mapped to a particular name. We used to do this with our file servers so that hosts wouldn't have to traverse a network boundary when accessing files and to spread the load out across the various NICs. The file servers would be homed on each of our various subnets, having multiple interface cards, each with a different subnet address, but the same name. The DNS servers on campus are still set up this way. Additionally, you may have a name that maps to more than one system, providing some level of load balancing via DNS.

这篇关于Dns.GetHostEntry 返回多个 IP 地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆