获取同一主机名的不同 IP 地址

获取同一主机名的不同 IP 地址

为什么在解析 CNAME 及其对应的 A 记录时,我会获得(看似)同一主机的不同 IP 地址?

❯ host www.github.com
www.github.com is an alias for github.com.
** github.com has address 100.87.99.25 **
github.com mail is handled by 5 alt1.aspmx.l.google.com.
github.com mail is handled by 1 aspmx.l.google.com.
github.com mail is handled by 10 alt3.aspmx.l.google.com.
github.com mail is handled by 5 alt2.aspmx.l.google.com.
github.com mail is handled by 10 alt4.aspmx.l.google.com.
❯ host github.com
** github.com has address 100.92.53.4 **
github.com mail is handled by 10 alt3.aspmx.l.google.com.
github.com mail is handled by 10 alt4.aspmx.l.google.com.
github.com mail is handled by 1 aspmx.l.google.com.
github.com mail is handled by 5 alt1.aspmx.l.google.com.
github.com mail is handled by 5 alt2.aspmx.l.google.com.

使用以下两个命令进行了测试: hostdig

答案1

因为该名称解析为多个 IP。

这是完全正常且合理的,你必须预料到。没有要求名称只能解析为一个 IP,也不要求即使在短时间内也保持一致。

相关内容