1、首先,配置正确的dns,既可以可视化界面操作

请输入图片描述

也可以命令行操作:

networksetup -setdnsservers Wi-Fi 8.8.8.8

查看

networksetup -getdnsservers Wi-Fi

2、此时再去ping域名的话,还是ping不通,但是ping ip地址却可以

ping www.baidu.com
ping: cannot resolve www.baidu.com: Unknown host

查看ip地址:

nslookup baidu.com

Server:        114.114.114.114
Address:    114.114.114.114#53

Non-authoritative answer:
Name:    baidu.com
Address: 110.242.68.66
Name:    baidu.com
Address: 39.156.66.10

然后ping ip:

ping 39.156.66.10
PING 39.156.66.10 (39.156.66.10): 56 data bytes
64 bytes from 39.156.66.10: icmp_seq=0 ttl=52 time=25.069 ms
64 bytes from 39.156.66.10: icmp_seq=1 ttl=52 time=23.747 ms
64 bytes from 39.156.66.10: icmp_seq=2 ttl=52 time=28.786 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域名,就可以了

标签: DNS,PING不通,MAC

添加新评论