为什么终端命令不在MacOS的/ etc / hosts中使用主机IP?

时间:2017-07-01 05:21:09

标签: git macos dns macos-sierra hosts

我已经将DNS IP添加到/ etc / hosts: $ cat / etc / hosts | grep -is googlesource

216.58.200.33   android.googlesource.com
216.58.200.33   android-review.googlesource.com
216.58.200.33   fuchsia.googlesource.com
216.58.200.33   googlesource.com
216.58.200.33   boringssl.googlesource.com
216.58.200.33   gerrit.googlesource.com
216.58.200.33   gerrit-review.googlesource.com
216.58.200.33   chromium.googlesource.com
216.58.200.33   kernel.googlesource.com
216.58.200.33   gwt.googlesource.com
216.58.200.33   code.googlesource.com
216.58.200.33   www.googlesource.com
216.58.200.33   go.googlesource.com
216.58.200.33   go-review.googlesource.com
216.58.200.33   cdn.googlesource.com

但是当我ping googlesource.com时,它也使用IP 74.125.204.82:

$ ping googlesource.com
PING googlesource.com (74.125.204.82): 56 data bytes
Request timeout for icmp_seq 0
Request timeout for icmp_seq 1
Request timeout for icmp_seq 2
Request timeout for icmp_seq 3
Request timeout for icmp_seq 4
Request timeout for icmp_seq 5
Request timeout for icmp_seq 6
Request timeout for icmp_seq 7
Request timeout for icmp_seq 8
^C
--- googlesource.com ping statistics ---
10 packets transmitted, 0 packets received, 100.0% packet loss

我使用git从googlesource.com克隆源代码,它仍然失败了:

$ git clone https://skia.googlesource.com/skia.git
Cloning into 'skia'...
fatal: unable to access 'https://skia.googlesource.com/skia.git/': Failed to connect to skia.googlesource.com port 443: Operation timed out

为什么呢? 如何强制git在/ etc / hosts中使用IP来解析URL?

1 个答案:

答案 0 :(得分:0)

需要

sudo killall -HUP mDNSResponder吗? (来源:https://www.imore.com/how-edit-your-macs-hosts-file-and-why-you-would-want