![获取同一主机名的不同 IP 地址](https://linux22.com/image/794411/%E8%8E%B7%E5%8F%96%E5%90%8C%E4%B8%80%E4%B8%BB%E6%9C%BA%E5%90%8D%E7%9A%84%E4%B8%8D%E5%90%8C%20IP%20%E5%9C%B0%E5%9D%80.png)
为什么在解析 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.
使用以下两个命令进行了测试: host
、dig
答案1
因为该名称解析为多个 IP。
这是完全正常且合理的,你必须预料到。没有要求名称只能解析为一个 IP,也不要求即使在短时间内也保持一致。