查看网络连接方式
networksetup -listallnetworkservices
An asterisk (*) denotes that a network service is disabled.
USB Ethernet
Wi-Fi
Bluetooth PAN
Thunderbolt Bridge
修改对应连接方式的DNS,多个DNS,空格隔开
sudo networksetup -setdnsservers “USB Ethernet” 8.8.8.8 8.8.4.4
查看USB网卡的DNS
networksetup -getdnsservers “USB Ethernet”
8.8.8.8
清空USB网卡的DNS
sudo networksetup -setdnsservers “USB Ethernet” empty
清空DNS缓存
dscacheutil -flushcache
通过文件查看DNS
cat /etc/resolv.conf
#
# Mac OS X Notice
#
# This file is not used by the host name and address resolution
# or the DNS query routing mechanisms used by most processes on
# this Mac OS X system.
#
# This file is automatically generated.
#
nameserver 8.8.8.8

本文介绍了如何在MacOS上使用命令行工具networksetup进行网络配置,包括查看网络服务状态、设置和清除DNS服务器以及查看DNS配置等内容。


被折叠的 条评论
为什么被折叠?



