networksetup:macOS上的终端网络配置管理工具 什么是 networksetup networksetup 是macOS自带的,作为 macOS 操作系统的一部分提供给用户的网络配置管理工具, 用户能在终端通过 networksetup 。管理网络设置和配置。 它提供了用于配置网络首选项、接口、代理、DNS 设置等的各种功能。
基本使用
1 2 3 4 5 6 7 networksetup -listallnetworkservices An asterisk (*) denotes that a network service is disabled. USB 10/100/1000 LAN Wi-Fi Thunderbolt Bridge
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 networksetup -listallhardwareports Hardware Port: Thunderbolt Bridge Device: bridge0 Ethernet Address: ******** Hardware Port: Wi-Fi Device: en0 Ethernet Address: ******** Hardware Port: Thunderbolt 1 Device: en1 Ethernet Address: ******** Hardware Port: Thunderbolt 2 Device: en2 Ethernet Address: ********
1 2 3 4 5 6 7 8 9 10 11 12 networksetup -setairportpower <device name> <on off> networksetup -getairportpower <device name> networksetup -setairportnetwork <device name> <network> [password] networksetup -getairportnetwork <device name>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 networksetup -setwebproxy <networkservice> <domain> <port number> <authenticated> <username> <password> networksetup -setsecurewebproxy <networkservice> <domain> <port number> <authenticated> <username> <password> networksetup -setproxybypassdomains <networkservice> <domain1> [domain2] [...] networksetup -setwebproxystate <networkservice> <on off> networksetup -setsecurewebproxystate <networkservice> <on off>