假脱机时,域名不能parsing

我有一个脆弱的DNS的把握。 但是,为了安装Wordpress MU的本地开发副本,我需要创build一个假域,我称之为local.dev。 它和所有子域名简单地parsing为127.0.0.1。 Apache然后指向正确的文件夹。

我安装了PowerDNS,并使用MySQL后端正常工作。 我感觉不舒服,但是因为它的工作,我没有再问任何问题。 奇怪的是它需要一个互联网连接才能正确parsing,现在我需要脱机使用它。

如果我离线,Chrome会提示错误:

Error 105 (net::ERR_NAME_NOT_RESOLVED): The server could not be found. 

/ etc / hosts文件

 127.0.0.1 localhost 

在/etc/resolv.conf

 nameserver 127.0.0.1 nameserver 8.8.8.8 nameserver 8.8.8.4 

当我挖掘,我得到同样的事情,在线或离线:

 dig local.dev ; <<>> DiG 9.6.1-P2 <<>> local.dev ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 10635 ;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 ;; WARNING: recursion requested but not available ;; QUESTION SECTION: ;local.dev. IN A ;; ANSWER SECTION: local.dev. 120 IN A 127.0.0.1 ;; Query time: 0 msec ;; SERVER: 127.0.0.1#53(127.0.0.1) ;; WHEN: Thu Apr 22 15:32:51 2010 ;; MSG SIZE rcvd: 43 

无论哪种情况,nslookup都找不到local.dev

 nslookup local.dev ;; Got recursion not available from 127.0.0.1, trying next server ;; Got recursion not available from 127.0.0.1, trying next server Server: 8.8.8.8 Address: 8.8.8.8#53 ** server can't find local.dev: NXDOMAIN 

PowerDNSconfiguration(注释删除):

 allow-recursion=127.0.0.1 allow-recursion-override=on 

如果您需要更多信息,我很乐意提供。

听起来好像你需要DNS服务器的本地主机条目,或者你的PowerDNS被设置为在检查其内部数据库之前从外部parsing地址。

忘记PowerDNS。 只需将必要的条目添加到您的主机文件。 像这样的东西:

 127.0.0.1 local.dev 

如果你有一个小的数量的子域,这比维护一个DNS服务要简单得多。

我只是注意到我们也发生了这种情况。 我有几个项目(〜30),我在其中工作的主机条目。 例如:

 127.0.0.1 localhost.example.com 127.0.0.1 localhost.mydomain.com 127.0.0.1 localhost.some-other-project.net 

…等等。

当我没有连接到networking时,我无法在Google Chrome中parsing这些名称。 在Firefox和Lynx中运行良好。 我可以ping localhost.example.com就好了。 看来Google Chrome的HostResolver拒绝使用hosts文件。

我在Ubuntu 10.04上使用Gogole Chrome 5.0.357.53。 (但是Google的一个快速search表明这也发生在Windows中)

按照以下步骤重新生成(在localhost上运行所需的Web服务器并响应“localhost.example.com”):

  • 添加主机文件条目:127.0.0.1 localhost.example.com
  • 断开表格networking(拔掉铜线,closures无线networking
    收音机等)
  • 打开Goog​​le Chrome
  • 转到:chrome://net-internals/hostresolver.trace
  • 点击“启用跟踪”
  • 打开新标签到localhost.example.com看到这个错误:

 Error 105 (net::ERR_NAME_NOT_RESOLVED): The server could not be found. 
  • 重新加载chrome://net-internals/hostresolver.trace标签。 显示:

 t=2085005: "Received request r608 for {hostname='localhost.example.com', port=80, priority=1, speculative=1, address_family=0, allow_cached=1, referrer=''}" t=2085005: "Created job j325 for {hostname='localhost.example.com', address_family=1}" t=2085005: "Attached request r608 to job j325" t=2085005: "Starting job j325" t=2085005: "[resolver thread] Running job j325" t=2085006: "[resolver thread] Completed job j325" t=2085006: "Completing job j325 (took 0 milliseconds)" t=2085006: "Finished request r608 with error=-105" t=2085207: "Received request r609 for {hostname='clients1.google.com', port=80, priority=3, speculative=0, address_family=0, allow_cached=1, referrer=''}" t=2085207: "Created job j326 for {hostname='clients1.google.com', address_family=1}" t=2085207: "Attached request r609 to job j326" t=2085207: "Starting job j326" t=2085207: "[resolver thread] Running job j326" t=2085207: "[resolver thread] Completed job j326" t=2085207: "Completing job j326 (took 0 milliseconds)" t=2085207: "Finished request r609 with error=-105" t=2085869: "Received request r610 for {hostname='localhost.example.com', port=80, priority=0, speculative=0, address_family=0, allow_cached=1, referrer=''}" t=2085869: "Finished request r610 with error=-105" t=2085889: "Received request r611 for {hostname='linkhelp.clients.google.com', port=80, priority=2, speculative=0, address_family=0, allow_cached=1, referrer=''}" t=2085889: "Created job j327 for {hostname='linkhelp.clients.google.com', address_family=1}" t=2085889: "Attached request r611 to job j327" t=2085889: "Starting job j327" t=2085889: "[resolver thread] Running job j327" t=2085889: "[resolver thread] Completed job j327" t=2085889: "Completing job j327 (took 0 milliseconds)" t=2085889: "Finished request r611 with error=-105