- 首先,配置正确的dns,既可以可视化界面操作
image.png
也可以命令行操作:
networksetup -setdnsservers Wi-Fi 8.8.8.8
查看
networksetup -getdnsservers Wi-Fi
- 此时再去ping域名的话,还是ping不通,但是ping ip地址却可以
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.57.216
Name: baidu.com
Address: 111.13.101.208
然后ping ip:
ping 111.13.101.208
PING 111.13.101.208 (111.13.101.208): 56 data bytes
64 bytes from 111.13.101.208: icmp_seq=0 ttl=49 time=31.815 ms
64 bytes from 111.13.101.208: icmp_seq=1 ttl=49 time=29.586 ms
64 bytes from 111.13.101.208: icmp_seq=2 ttl=49 time=32.358 ms
^C
--- 111.13.101.208 ping statistics ---
3 packets transmitted, 3 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 29.586/31.253/32.358/1.199 ms
3.解决办法
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist
然后ping域名,就可以了
网友评论