鉴于天朝的网络,这DNS服务器是要随时改啊,一直以来网络不稳定的做法:
依次点击 偏好设置- 网络 - 高级 - DNS - + ..........
累觉不爱啊,每次都要点,况且DNS要那么频繁的更改,还想不想好好上网了!
Shell才是王道啊,方法如下
# 其实就是用到networksetup命令 # 设置DNS sudo networksetup -setdnsservers <workservices> x.x.x.x # 注:x.x.x.x就是要更改的DNS地址,可以加空格跟多个 # <workservices>是要修改的网络接口,需要替换,不知道可以运行下列命令 networksetup -listallnetworkservices # 查看当前设置的DNS networksetup -getdnsservers <workservices> # 清空当前DNS(自动获取) sudo networksetup -setdnsservers <workservices> empty # 顺便把几个DNS地址转了: # # Google DNS IPv4地址: # 8.8.8.8 (google-public-dns-a.google.com) # 8.8.4.4 (google-public-dns-b.google.com) # Google DNS IPv6地址: # 2001:4860:4860::8888 # 2001:4860:4860::8844 # OpenDNS IPv4地址: # 208.67.222.222 (Resolver1.OpenDNS.com) # 208.67.220.220 (Resolver2.OpenDNS.com) # 208.67.222.220 (Resolver3.OpenDNS.com) # 208.67.220.222 (Resolver4.OpenDNS.com) # OpenDNS IPv6地址: # 2620:0:ccc::2 # 2620:0:ccd::2 #