This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(2)
1)像这样的问题确实应该放在ServerFault上。
2) 127.0.0.1 是本地主机,不是可公开访问的地址。恕我直言,如果您不明白这一点,您应该回到共享主机...您最终会花费更多的时间来学习运行 VPS,而不是让您的网站正常运行。 (如果您只是使用 127.0.0.1 作为占位符,则这不适用。)
3) 大多数没有复杂需求的个人可能应该选择使用其域名注册商的 DNS 服务器(如果可用)(例如 NameCheap)。如果您的注册商不提供免费 DNS,您的 VPS 提供商几乎肯定会提供(我知道 Linode 和 Rackspace Cloud 都提供)。无论您在何处托管 DNS,您都需要在配置中使用它们的名称服务器,而不是您发明的地址。 (您实际上不会使用 djbdns 或 BIND 运行您自己的名称服务器,对吧?)
编辑:在问题澄清后尝试解释 DNS。
您的问题仍然不太清楚,我认为这是因为我们没有使用相同的术语。 DNS 是一个复杂的系统,您必须非常精确。
让我尝试根据您的情况解释 DNS 层次结构的排列方式。
1) 您注册一个域名 example.com。它位于 .com 顶级域 (TLD) 中。每个 TLD 都有一个实体来管理该 TLD 的根名称服务器。就 .com 而言,这是 Verisign。当有人查找 www.example.com 时,他们首先与 TLD 的根名称服务器进行对话(通过此处并不真正相关的过程)。
2) 根域名服务器返回域 (example.com) 的权威域名服务器。我相信这就是你想要设置的。根据 DNS 规范,权威名称服务器是通过名称而不是 IP 给出的。由于您(希望)并不尝试运行自己的权威域名服务器,因此您应该向您的注册商(反过来又告诉 TLD 根域名服务器)您的托管公司指定的域名服务器;这些是在我在评论中给您的链接中提供的(ns1.ixwebhosting.com 等)。 这些需要是名称而不是 IP 的原因是您的托管公司稍后可能需要移动 IP 地址。如果您被允许输入 IP,而他们切换了 IP,您的记录就会丢失的日期。通过输入名称,DNS 系统可以将权威名称服务器名称正确解析为 IP。
3) 对 www.example.com 感兴趣的客户端,已获取 example.com 的权威名称服务器(即 ns1.ixwebhosting.com)的名称(并解析了 IP),联系权威名称服务器并请求 IP对于 www.example.com。权威名称服务器检查其记录并返回您告诉它的IP。也就是说,您将使用托管提供商的界面(可能是您登录的网页...联系他们寻求帮助)来管理 example.com 的子域,例如 www.example.com。
如果您不使用托管 DNS,则必须运行自己的 DNS 服务器(例如 BIND 或 djbdns)。这引入了一系列超出您问题范围的其他复杂情况。请仅使用托管 DNS,并让您的提供商处理这些问题。
您会注意到我在这里没有提到 ns1.example.com。仅当您运行自己的 DNS 服务器时才需要处理此类记录,但您可能不应该这样做。
总之:
1) 告诉您的注册商您的域使用托管提供商的 DNS 服务器(来自我给您的链接)。
2) 告诉您的托管提供商使用您的 VPS 的 IP 地址作为您域的实际主机名。
这样事情就清楚了吗?
1) Questions such as this should really be on ServerFault.
2) 127.0.0.1 is localhost, not a publicly accessible address. Respectfully, if you didn't understand this, you should go back to shared hosting... you will end up spending more time learning to run a VPS than making your site work. (If you were just using 127.0.0.1 as a placeholder, then this doesn't apply.)
3) Most individuals who don't have complex needs should probably just opt to use their domain registrar's DNS servers if available (e.g. NameCheap). If your registrar doesn't offer free DNS, your VPS provider almost certainly does (I know both Linode and Rackspace Cloud do). Regardless of where you are having DNS hosted, you need to use their name servers in your configuration, not addresses you invent. (You're not actually going to run your own name server with djbdns or BIND, right?)
EDIT: Attempt to explain DNS after question clarification.
Your question still isn't really clear, and I think it's because we aren't using the same terminology. DNS is a complicated system and you have to be very precise.
Let me try to explain the how DNS hierarchies are arranged as relates to your situation.
1) You register a domain, example.com. It is in the .com top-level domain (TLD). Each TLD has a single entity who manages the root nameserver for that TLD. In the case of .com, this is Verisign. When someone goes to look up www.example.com, they first talk (through a process that isn't really relevant here) to the TLD's root nameserver.
2) The root nameserver returns the authoritative nameserver(s) for the domain (example.com). This is what I believe you are trying to set. According to the DNS specification, the authoritative nameservers are given by name, not IP. Since you (hopefully) aren't trying to run your own authoritative nameserver, you should give your registrar (who in turn tells the TLD root nameserver) the nameservers designated by your hosting company; these were supplied in the link I gave you in the comments (ns1.ixwebhosting.com, etc.). The reason these need to be names, not IPs, is that your hosting company may need to move IP addresses later. If you were allowed to enter an IP, and they switched IPs, your record would be out of date. By entering a name, the DNS system can properly resolve the authoritative nameserver name to an IP.
3) The client interested in www.example.com, having obtained the name (and resolved the IP) for the authoritative name server for example.com (i.e., ns1.ixwebhosting.com), contacts the authoritative name server and requests the IP for www.example.com. The authoritative name server checks its records and returns the IP that you have told it. That is, you will use your hosting provider's interface (probably a web page you login to... contact them for assistance) to manage the subdomains for example.com, such as www.example.com.
If you don't use hosted DNS, you have to run your own DNS server (e.g. BIND or djbdns). This introduces a whole set of other complications that are beyond the scope of your question. Please just use hosted DNS and let your provider deal with these issues.
You will notice that nowhere here did I mention ns1.example.com. You only need to deal with such records if you are running your own DNS server, which you probably shouldn't be doing.
So in summary:
1) Tell your registrar that your domain uses your hosting provider's DNS servers (from the link I gave you).
2) Tell your hosting provider to use your VPS' IP address for actual host names for your domain.
Does that clear things up?
我在 serverfault 上有一个与此类似的问题,但它被否决了,但没有人解释为什么它不能完成。在研究网络寻找 DNS 原理之后,以下是我关于为什么不能用 IP 代替名称服务器的答案。虽然很长,但也有助于我理解约定。
假设您注册了域名
abc123.com
,其中“com”是顶级域名,“abc123”部分是二级域名。当网络用户想要访问
abc123.com
时,他会在网络浏览器中输入abc123.com
。然后,浏览器联系 DNS 解析器(例如 google DNS、level3 或 opendns——充当缓存)来查询 DNS 解析器是否具有先前保存的 abc123.com 的 IP 地址。如果有人之前尝试通过此解析器访问abc123.com
,则解析器应具有 abc123.com 域名的 IP 地址,并将该 IP 返回给浏览器。但是,如果没有人向 DNS 解析器查询过 abc123.com,则解析器不会缓存该 IP。然后,解析器需要联系根 DNS 服务器以获取该信息。根 DNS 服务器的工作方式解释了为什么不能用 IP 替代传统的字母数字名称服务器名称。根 DNS 服务器从域注册商获取其信息。当您注册abc123.com域名时,abc123.com被根DNS服务器记录;以及名称服务器/IP(可选)。
我认为为什么名称服务器名称必须遵循 FQDN(完全限定域名)格式是因为根 DNS 服务器的设计工作方式。例如,对于
ns1.mynameserver.com
名称服务器名称,猜测是“mynameserver.com”必须存在于根 DNS 服务器中,因为它能够在逻辑上表示ns1.mynameserver。 com
才有效。如果记录中不存在mynameserver.com
,则ns1.mynameserver.com
一定无效。对于作为名称服务器名称的 IP 也是如此,根 DNS 服务器永远无法将您的 IP 记录为有效域名(因为 IP 不是有效的 FQDN 格式,没有数字顶级域 - 即.42
目前不是有效的 TLD)。回到最初的问题,即是否可以使用 IP 地址作为名称服务器名称。即使您选择忽略约定,您也不可能将 IP 设置为名称服务器名称,因为您的注册商不允许这样做。如果您拥有 abc123.com 并登录到注册商注册域名服务器名称,则顶级域名(“.com”)和二级域名(“abc123”)将被锁定。您只能输入子级别域的值。因此,您最终可能会得到
12.23.45.33.abc123.com
作为您的域名服务器名称(也就是说,如果您的注册商允许您拥有那么多点)。I had a similar question to this one over at serverfault, but it got voted down but no one offered to explain why it can't be done. After researching the web looking for DNS principles, here is my answer as to why you can't substitute IPs for nameservers. It is long, but it also helps me understand the convention.
Let's say you registered the domain
abc123.com
, the "com" is the top level domain, the "abc123" part is the second level domain.When a web user wants to visit
abc123.com
, he types inabc123.com
into his web browser. The browser then contact the DNS resolver (such as google DNS, level3, or opendns -- which is acting as a cache) to query if the DNS resolver has the IP address for abc123.com previously saved. If some one had tried to reachabc123.com
previously through this resolver, the resolver should have the IP address for the abc123.com domain name and return the IP to the browser. But if no has ever queried the DNS resolver for abc123.com, the resolver does not have the IP cached. The resolver then need to contact the root DNS server for that information.The root DNS server works in a way that explains why you can't substitute IP for conventional alphanumeric nameserver names. The root DNS server gets its info from the domain registrars. When you register the abc123.com domain, abc123.com is recorded by the root DNS server; along with the nameservers/IP (optional).
I think why the nameserver names have to follow the FQDN (fully qualified domain name) format is because of the way the root DNS server is designed to work. Example, for
ns1.mynameserver.com
nameserver name, the guess is that the "mynameserver.com" must exist in the root DNS server for it be able to logically say thatns1.mynameserver.com
to be valid. Ifmynameserver.com
does not exist in the record, thenns1.mynameserver.com
must not be valid. The same goes for the IP as nameserver name, the root DNS server can never have your IP on record as a valid domain name (because the IP is not a valid FQDN format, there is no numeric top level domain -- ie.42
is currently not a valid TLD).Going back to the original question as to whether you can use IP addresses as nameserver names. Even if you choose to ignore convention, it is not possible for you to set IP as nameserver names because your registrar won't allow it. If you own abc123.com and you log into your registrar to register nameserver names, the top (".com") and second ("abc123") level domains are locked. You can only enter values for the sub level domain. So what you could end up with is
12.23.45.33.abc123.com
as your nameserver name (that is if your registrar allows you to have that many dots).