1 | networksetup -listallnetworkservices |
得到所有接口(interfaces).
1 | networksetup -setdnsservers {INTERFACE NAME} {YOUR DNS SERVER} |
设置DNS.
1 | networksetup -setdnsservers {INTERFACE NAME} {YOUR DNS SERVER} {YOUR DNS SERVER} |
如果有多个DNS,那么用空格隔开。
之后就可以用ifconfig查看修改了。
networksetup更多参数可以查看:
https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man8/networksetup.8.html