如何将域名解析为单个 IP 地址? [英] How to resolve a domain name to a single IP address?

查看:68
本文介绍了如何将域名解析为单个 IP 地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我惊讶地发现一个域名可以有多个 IP 地址.例如,以下是我对 Dns.GetHostAddresses("www.google.com") 的结果:

I was surprised to learn that a single domain name can have many IP addresses. For example, here are my results for Dns.GetHostAddresses("www.google.com"):

{System.Net.IPAddress[6]}
    [0]: {74.125.127.147}
    [1]: {74.125.127.99}
    [2]: {74.125.127.103}
    [3]: {74.125.127.104}
    [4]: {74.125.127.105}
    [5]: {74.125.127.106}

(YMMV;地址似乎定期更改)

(YMMV; the addresses seem to change periodically)

这些不同的地址来自哪里,应该如何选择要连接的 IP 地址?

Where do these different addresses come from, and how should one choose an IP address to connect to?

推荐答案

IP 地址来自与查询域名关联的 DNS 服务器,在您的示例中为 www.google.com.这与 Web 浏览器获取要连接的服务器 IP 地址所遵循的过程相同.

The IP addresses come from the DNS server associated with the queried domain name, www.google.com in your example. This would be the same process a web browser follows to get the server IP addresses to connect to.

至于连接到哪个 IP 地址,我想它们都是多余的,您可能应该只连接到第一个,但这只是猜测,我不确定.

As for which IP address to connect to I'd imagine they're all redundant and you should probably just connect to the first one, however this is just speculation and I don't really know for sure.

这篇关于如何将域名解析为单个 IP 地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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