我们常常使用 Linux 的 Hostname 来标识一台服务器。Phil KarIton 曾说过:
计算机科学只存在两个难题:命名和缓存失效。
如何想出一个有意义、便于运维,甚至有个人风格(对于个人服务器来说)的 Hostname 也是一件难事。曾有一个有趣的 RFC —— RFC 1178: Choosing a Name for Your Computer 给出了一些关于命名 Hostname 的建议。
在这份 RFC 中,曾经提到了「不要使用域名或类似域名的东西作为主机名」:
Avoid domain names.
For technical reasons, domain names should be avoided. In particular, name resolution of non-absolute hostnames is problematic. Resolvers will check names against domains before checking them against hostnames. But we have seen instances of mailers that refuse to treat single token names as domains. For example, assume that you mail to “libes@rutgers” from yale.edu. Depending upon the implementation, the mail may go to rutgers.edu or rutgers.yale.edu (assuming both exist).Avoid domain-like names.
Domain names are either organizational (e.g., cia.gov) or geographical (e.g., dallas.tx.us). Using anything like these tends to imply some connection. For example, the name “tahiti” sounds like it means you are located there. This is confusing if it is really somewhere else (e.g., “tahiti.cia.gov is located in Langley, Virginia? I thought it was the CIA’s Tahiti office!”). If it really is located there, the name implies that it is the only computer here. If this isn’t wrong now, it inevitably will be There are some organizational and geographical names that work fine. These are exactly the ones that do not function well as domain names. For example, amorphous names such as rivers, mythological places and other impossibilities are very suitable. (“earth” is not yet a domain name.)
使用域名作为 Hostname 不仅是一个技术错误,还会带来潜在的信息安全问题,尤其是对于使用二级域名(例如 example.com
)来说。就在刚刚,我碰到了一个生动的例子。