2013-02-25 138 views
9

我已经安装RasPi Raspbian,现在我不能做ssh或git clone,只有本地主机名正在被解析。然而Ping原理:无法解析主机名,ping工程

pi ~ $ ssh test.com 
ssh: Could not resolve hostname test.com: Name or service not known 

pi ~ $ git clone [email protected]:test.git 
Cloning into 'test'... 
ssh: Could not resolve hostname test.com: Name or service not known 
fatal: The remote end hung up unexpectedly 

pi ~ $ ping test.com 
PING test.com (174.36.85.72) 56(84) bytes of data. 

我周围那种工作了github上使用http://github.com代替git://github.com,但是这是不正常的,我想查明问题。

谷歌搜索类似的问题,但提供的解决方案是打字错误更正或添加域到主机文件。

+2

如果您可以ping通,请尝试使用IP地址。 'git clone [email protected]:test.git'。我还会看看'nslookup test.com'以确保它正确解析。 – 2013-02-25 01:07:01

+0

当然,我可以使用IP地址,但我想彻底解决它。最重要的是 - 了解是什么造成的。 – firedev 2013-02-25 03:30:21

回答

19

这听起来像一个DNS问题。尝试切换到另一台DNS服务器,看看它是否有效。

OpenDNS的

  • 208.67.222.222
  • 208.67.220.220

GoogleDNS

  • 8.8.8.8
  • 8.8.4.4
+0

谁能想到!在使用nslookup之后,我看到有一些递归正在进行:';;从203.144.206.49开始无法获得递归,尝试下一个服务器,改用Google DNS修复它。谢谢! – firedev 2013-02-25 03:41:02

+0

哈哈,它有时会发生,特别是当一件事情似乎有效。真高兴你做到了! – chirinosky 2013-02-25 05:21:49

+0

在我的情况下,我在/etc/resolv.conf中添加了以下几行: nameserver 8.8.8.8 nameserver 8.8.4.4 – Nobu 2013-04-22 20:24:31

-1

如果您在一个网络管理员安装

检查/etc/nsswitch.conf中

,如果你已经有了一个线

hosts:   files mdns4_minimal [NOTFOUND=return] dns mdns4 

remove the **[NOTFOUND=return]** 

restart /etc/init.d/networking 

the [NOTFOUND=return] prevents futher lookups if the first nameservwe doesn't respond correctly 
1

有同样的错误,我只是需要指定文件夹:

localmachine $ git pull ssh://[email protected]:38765 
ssh: Could not resolve hostname : No address associated with hostname 
fatal: The remote end hung up unexpectedly 

localmachine $ git pull ssh://[email protected]:38765/ 
[email protected]'s password: 

该错误消息只是误导。

2

尝试重新设置DNS客户端解析程序缓存的内容。 (适用于Windows)Fireup命令提示符下,键入:

ipconfig /flushdns 

如果你是一个Linux或Mac用户,他们有自己的刷新DNS的方式。

-1

这可能是代理的问题。请不要犹豫,试试。

git config --global --unset http.proxy 
git config --global --unset https.proxy