突然电脑上的 SVN 链接不上了,试着 ping 了一下域名,发现所有域名都ping 不通,但 IP 却可以 ping 通,估计都是本机 DNS 服务器设置出问题了。
解决方法:
首先,配置正确的dns,既可以可视化界面操作
也可以命令行操作:networksetup -setdnsservers Wi-Fi 8.8.8.8
查看:networksetup -getdnsservers Wi-Fi
以上一般就可以了。
如果依然 ping 不通,尝试继续按如下方式解决:
ping www.baidu.com
ping: cannot resolve www.baidu.com: Unknown host
查看ip地址:nslookup baidu.com
Server: 8.8.8.8
Address: 8.8.8.8#53
Non-authoritative answer:
Name: baidu.com
Address: 220.181.38.148
Name: baidu.com
Address: 39.156.69.79
然后ping 39.156.69.79
➜ ~ ping 39.156.69.79
PING 39.156.69.79 (39.156.69.79): 56 data bytes
64 bytes from 39.156.69.79: icmp_seq=0 ttl=48 time=40.310 ms
64 bytes from 39.156.69.79: icmp_seq=1 ttl=48 time=38.929 ms
解决办法
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist
然后ping域名,就可以了