1.錯誤信息
之前github都能用,但是今天git clone的時候居然連不上了,報錯信息如下:
$ git clone git@github.com:hanchao5272/myreflect.git
Cloning into 'myreflect'... ssh_dispatch_run_fatal: Connection to 13.250.177.223 port 22: Software caused connection abort fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
2.錯誤分析
於是懷疑是連接不到github.com了,首先在cmd窗口中,嘗試ping一下百度
C:\Users\hanchao>ping www.baidu.com 正在 Ping www.a.shifen.com [61.135.169.121] 具有 32 字節的數據: 來自 61.135.169.121 的回復: 字節=32 時間=24ms TTL=57 來自 61.135.169.121 的回復: 字節=32 時間=45ms TTL=57 來自 61.135.169.121 的回復: 字節=32 時間=26ms TTL=57 來自 61.135.169.121 的回復: 字節=32 時間=22ms TTL=57 61.135.169.121 的 Ping 統計信息: 數據包: 已發送 = 4,已接收 = 4,丟失 = 0 (0% 丟失), 往返行程的估計時間(以毫秒為單位): 最短 = 22ms,最長 = 45ms,平均 = 29ms
說明網絡連接正常。
然后再ping一下github.com
C:\Users\hanchao>ping github.com 正在 Ping github.com [13.229.188.59] 具有 32 字節的數據: 請求超時。 請求超時。 請求超時。 請求超時。 13.229.188.59 的 Ping 統計信息: 數據包: 已發送 = 4,已接收 = 0,丟失 = 4 (100% 丟失),
確實ping不通。
因此懷疑是:本地DNS無法解析導致的。
3.錯誤解決
打開C:\Windows\System32\drivers\etc\hosts,內容如下:
# Copyright (c) 1993-2009 Microsoft Corp. # # This is a sample HOSTS file used by Microsoft TCP/IP for Windows. # # This file contains the mappings of IP addresses to host names. Each # entry should be kept on an individual line. The IP address should # be placed in the first column followed by the corresponding host name. # The IP address and the host name should be separated by at least one # space. # # Additionally, comments (such as these) may be inserted on individual # lines or following the machine name denoted by a '#' symbol. # # For example: # # 102.54.94.97 rhino.acme.com # source server # 38.25.63.10 x.acme.com # x client host # localhost name resolution is handled within DNS itself. # 127.0.0.1 localhost # ::1 localhost 0.0.0.0 account.jetbrains.com
發現:確實沒有github.com的解析
在文件末尾添加如下內容,並保存:
192.30.255.112 github.com git 185.31.16.184 github.global.ssl.fastly.net
重啟cmd窗口,繼續ping一下github.com:
正在 Ping github.com [192.30.255.112] 具有 32 字節的數據: 來自 192.30.255.112 的回復: 字節=32 時間=311ms TTL=48 來自 192.30.255.112 的回復: 字節=32 時間=365ms TTL=48 來自 192.30.255.112 的回復: 字節=32 時間=376ms TTL=48 來自 192.30.255.112 的回復: 字節=32 時間=353ms TTL=48 192.30.255.112 的 Ping 統計信息: 數據包: 已發送 = 4,已接收 = 4,丟失 = 0 (0% 丟失), 往返行程的估計時間(以毫秒為單位): 最短 = 311ms,最長 = 376ms,平均 = 351ms
- 說明,本機已經能夠正常解析
github.com這個域名了。至此,問題解決
