NETWORKSETUP(8) System Manager's Manual NETWORKSETUP(8)

networksetupconfiguration tool for network settings in System Preferences.

networksetup [-listnetworkserviceorder] [-listallnetworkservices] [-listallhardwareports] [-detectnewhardware] [-getmacaddress hardwareport] [-getcomputername] [-setcomputername computername] [-getinfo networkservice] [-setmanual networkservice ip subnet router] [-setdhcp networkservice [clientid]] [-setbootp networkservice] [-setmanualwithdhcprouter networkservice ip] [-getadditionalroutes networkservice] [-setadditionalroutes networkservice [dest1 mask1 gate1] [dest2 mask2 gate2] ... [destN maskN gateN]] [-setv4off networkservice] [-setv6off networkservice] [-setv6automatic networkservice] [-setv6linklocal networkservice] [-setv6manual networkservice address prefixLength router] [-getv6additionalroutes networkservice] [-setv6additionalroutes networkservice [dest1 prefixlength1 gate1] [dest2 prefixlength2 gate2] ... [destN prefixlengthN gateN]] [-getdnsservers networkservice] [-setdnsservers networkservice dns1 [dns2] [...]] [-getsearchdomains networkservice] [-setsearchdomains networkservice domain1 [domain2] [...]] [-create6to4service networkservicename] [-set6to4automatic networkservice] [-set6to4manual networkservice relayAddress] [-getwebproxy networkservice] [-setwebproxy networkservice domain portnumber authenticated username password] [-setwebproxystate networkservice on | off] [-getsecurewebproxy networkservice] [-setsecurewebproxy networkservice domain portnumber authenticated username password] [-setsecurewebproxystate networkservice on | off] [-getsocksfirewallproxy networkservice] [-setsocksfirewallproxy networkservice domain portnumber authenticated username password] [-setsocksfirewallproxystate networkservice on | off] [-getproxybypassdomains networkservice] [-setproxybypassdomains networkservice domain1 [domain2] [...]] [-getproxyautodiscovery networkservice] [-setproxyautodiscovery networkservice on | off] [-getairportnetwork device] [-setairportnetwork device network [password]] [-getairportpower device] [-setairportpower device on | off] [-listpreferredwirelessnetworks hardwareport] [-addpreferredwirelessnetworkatindex hardwareport network index securitytype [password]] [-removepreferredwirelessnetwork hardwareport network] [-removeallpreferredwirelessnetworks hardwareport] [-getnetworkserviceenabled networkservice] [-setnetworkserviceenabled networkservice on | off] [-createnetworkservice networkservicename hardwareport] [-renamenetworkservice networkservice newnetworkservicename] [-duplicatenetworkservice networkservice newnetworkservicename] [-removenetworkservice networkservice] [-ordernetworkservices service1 [service2] [service3] [...]] [-getMTU hardwareport] [-setMTU hardwarePort value] [-listvalidMTUrange hardwareport] [-getmedia hardwareport] [-setmedia hardwareport subtype [option1] [option2] [...]] [-listvalidmedia hardwareport] [-createVLAN name parentdevice tag] [-deleteVLAN name parentdevice tag] [-listVLANs] [-listdevicesthatsupportVLAN] [-isBondSupported device] [-createBond name [device1] [device2] [...]] [-deleteBond bond] [-addDeviceToBond device bond] [-removeDeviceFromBond device bond] [-listBonds] [-showBondStatus bond] [-listpppoeservices] [-showpppoestatus name] [-createpppoeservice device name account password [pppoeName]] [-deletepppoeservice service] [-setpppoeaccountname service account] [-setpppoepassword service password] [-connectpppoeservice service] [-disconnectpppoeservice service] [-listlocations] [-getcurrentlocation] [-createlocation location [populate]] [-deletelocation location] [-switchtolocation location] [-version] [-help] [-printcommands]

The networksetup command is used to configure network settings typically configured in the System Preferences application. The networksetup command requires at least admin privileges to change network settings. If the "Require an administrator password to access system-wide preferences" option is selected in System Preferences > Security & Privacy, then root privileges are required to change network settings.

Any flag that takes a password will accept "-" in place of the password to indicate it should read the password from stdin.

A list of flags and their descriptions:

Displays a list of network services in the order they are contacted for a connection, along with the corresponding port and device for each. An asterisk (*) next to a service means the service is inactive.
Displays a list of all the network services on the server's hardware ports. An asterisk (*) denotes that a network service is disabled.
Displays list of hardware ports with corresponding device name and ethernet address.
Detects new network hardware and creates a default network service on the hardware.
hardwareport
Displays ethernet (or Wi-Fi) address for hardwareport or device specified.
Displays the computer name.
computername
Sets computer name to <computername>. This name is used by AFP.
networkservice
Displays the IP address, subnet mask, router, and hardware address for the <networkservice> that you specify.
networkservice ip subnet router
Set the TCP/IP configuration for <networkservice> to manual with IP address set to <ip>, Subnet Mask set to <subnet>, and Router address set to <router>.
networkservice [clientid]
Use this command to set the TCP/IP configuration for the specified <networkservice> to use DHCP. The client ID is optional. Specify "Empty" for [clientid] to clear the DHCP client id.
networkservice
Use this command to set the TCP/IP configuration for the specified <networkservice> to use BOOTP.
networkservice ip
Use this command to specify a manual IP address to use for DHCP for the specified <networkservice>.
networkservice
Use this command to display the list of additional IPv4 routes configured for the service.
networkservice [dest1 mask1 gate1] [dest2 mask2 gate2] ... [destN maskN gateN]
Use this command to set the list of IPv4 additional routes configured for the service. Each route is specified as a (destination address, subnet mask, gateway address) tuple. Specifying no tuples clears the list of routes.
networkservice
Use this command to turn IPv4 off on the specified <networkservice>.
networkservice
Use this command to turn IPv6 off on the specified <networkservice>.
networkservice
Use this command to set IPv6 to get its addresses automatically for <networkservice>.
networkservice
Use this command to set IPv6 to only use link local for <networkservice>.
ip prefixlength router
Use this command to set IPv6 to get its addresses manually for <networkservice>. Specify the ip address, the prefix length and the router.
networkservice
Use this command to display the list of additional IPv6 routes configured for the service.
networkservice [dest1 prefixlength1 gate1] [dest2 prefixlength2 gate2] ... [destN prefixlengthN gateN]
Use this command to set the list of additional routes configured for the service. Each route is specified as a
(destination address, prefix length, gateway address) tuple. Specifying no tuples clears the list of routes.
networkservice
Displays DNS info for <networkservice>.
networkservice dns1 [dns2] [...]
Use this command to specify the IP addresses of servers you want the specified <networkservice> to use to resolve domain names. You can list any number of servers (replace dns1, dns2, and so on with the IP addresses of domain name servers). If you want to clear all DNS entries for the specified network service, type "empty" in place of the DNS server names.
networkservice
Displays Domain Name info for <networkservice>.
networkservice domain1 [domain2] [...]
Use this command to designate the search domain for the specified <networkservice>. You can list any number of search domains (replace domain1, domain2, and so on with the name of a local domain). If you want to clear all search domain entries for the specified network service, type “empty” in place of the domain name.
-<newnetworkservicename>
Use this command to create a new 6 to 4 service with name <newnetworkservicename>.
-<newnetworkservicename>
Use this command to set the 6 to 4 service such that it will get the relay address automatically.
-<newnetworkservicename> -<relayaddress>
Use this command to set the 6 to 4 service such that it will get the relay address manually. Specify the <relayaddress> that you would like to set.
networkservice
Displays Web proxy (server, port, enabled value) info for <networkservice>.
networkservice domain portnumber authenticated username password
Set Web proxy for <networkservice> with <domain> and <port number>. Turns proxy on. Optionally, specify <on> or <off> for <authenticated> to enable and disable authenticated proxy support. Specify <username> and <password> if you turn authenticated proxy support on.
networkservice on | off
Set Web proxy on <networkservice> to either <on> or <off>.
networkservice
Displays Secure Web proxy (server, port, enabled value) info for <networkservice>.
networkservice domain portnumber authenticated username password
Set Secure Web proxy for <networkservice> with <domain> and <port number>. Turns proxy on. Optionally, specify <on> or <off> for <authenticated> to enable and disable authenticated proxy support. Specify <username> and <password> if you turn authenticated proxy support on.
networkservice on | off
Set SecureWeb proxy on <networkservice> to either <on> or <off>.
networkservice
Displays SOCKS Firewall proxy (server, port, enabled value) info for <networkservice>.
networkservice domain portnumber authenticated username password
Set SOCKS Firewall proxy for <networkservice> with <domain> and <port number>. Turns proxy on. Optionally, specify <on> or <off> for <authenticated> to enable and disable authenticated proxy support. Specify <username> and <password> if you turn authenticated proxy support on.
networkservice on | off
Set SOCKS Firewall proxy to either <on> or <off>.
networkservice
Displays Bypass Domain Names for <networkservice>.
networkservice domain1 [domain2] [...]
Set the Bypass Domain Name Servers for <networkservice> to <domain1> [domain2] [...]. Any number of Domain Name servers can be specified. Specify "Empty" for <domain1> to clear all Domain Name entries.
networkservice
Displays Proxy Auto Discover for <networkservice>.
networkservice on | off
Set Proxy Auto Discover for <networkservice> to either <on> or <off>.
networkservice url
Set proxy auto-config to url for <networkservice> and enable it.
networkservice
Displays proxy auto-config (url, enabled) info for <networkservice>.
networkservice on | off
Set SOCKS Firewall proxy to either <on> or <off>.
hardwareport
Displays current Wi-Fi Network.
hardwareport network [password]
Set Wi-Fi Network to <network> using optional [password] if specified.
hardwareport
Displays whether Wi-Fi power is on or off.
hardwareport on | off
Set Wi-Fi power to either <on> or <off>.
hardwareport
List the preferred wireless networks for <hardwareport>
hardwareport network index securitytype [password]
Add wireless network named <network> to preferred list for <hardwareport> at <index>. Store the optional password in the keychain For security type, use OPEN for none, WPA for WPA Personal, WPA2 for WPA2 Personal, WPA/WPA2 for WPA/WPA2 Personal, WPAE for WPA Enterprise, WPA2E for WPA2 Enterprise, WPAE/WPA2E for WPA/WPA2 Enterprise, WEP for plain WEP, and 8021XWEP for 802.1X WEP.
hardwareport network
Remove <network> from the preferred wireless network list for <hardwareport>
hardwareport
Remove all networks from the preferred wireless network list for <hardwareport>
networkservice
Displays whether a service is on or off (enabled or disabled).
networkservice on | off
Use this command to turn the specified network service on or off (enable or disable).
networkservicename hardwareport
Create a service named <networkservice> on port <hardwareport>. The new service will be enabled by default.
networkservice newnetworkservicename
Use this command to rename the specified network service <networkservice> to <newnetworkservicename>.
networkservice newnetworkservicename
Use this command to duplicate an existing network service <networkservice> and rename it to the specified name <newnetworkservicename>.
networkservice
Use this command to delete a network service <networkservice>. You cannot use this command to delete the last remaining service for a hardware port. To do so, you use the -setnetworkserviceenabled command.
service1 [service2] [service3] [...]
Use this command to designate the order network services are contacted on the specified hardware port. Name the network you want contacted first, then the second, and so on. Use "listnetworkserviceorder" to view current service order. Note: use quotes around service names which contain spaces (ie. "Built-in Ethernet").
hardwarePort
Set hardwareport or device specified back to automatically setting the MTU and Media.
hardwareport
Get the MTU value for hardwareport or device specified.
hardwarePort value
Set MTU for hardwareport or device specified.
hardwareport
List the valid MTU range for hardwareport or device specified.
hardwareport
Show both the current setting for media and the active media on hardwareport or device specified.
hardwareport subtype [option1] [option2] [...]
Set media for hardwareport or device specified to subtype. Specify optional [option1] and additional options depending on subtype. Any number of valid options can be specified.
hardwareport
List valid media options for hardwareport or device name. Enumerates available subtypes and options per subtype.
name parentdevice tag
Create a VLAN with the name <name> over the parent device <parentdevice> and with the tag <tag>.
name parentdevice tag
Delete the VLAN with the name <name> over the parent device <parentdevice> and with the tag <tag>.
List the VLANs that have been created.
List the devices that support VLANs.
device
Displays YES if the device can be added to a bond. NO if it cannot.
name [device1] [device2] [...]
Create a bond with the user-defined-name name and optionally add any listed devices if they support bonding.
bond
Delete the bond with the specified device-name.
device bond
Add device to bond.
device bond
Remove device from bond.
List of all bonds.
bond
Display the status of the specified bond.
List all PPPoE services in the current set.
name
Display the status of the PPPoE service with the specified name.
device name account password [pppoeName]
Create a PPPoE service on the specified device with the service name specified.
service
Delete the service.
service account
Set the account name for the service.
service password
Set the password for the service.
service
Connect the service.
service
Disconnect the service.
List all network locations.
Display the name of the current set.
location [populate]
Create a set with the user-defined-name name and optionally populate it with the default services.
location
Delete the set.
location
Make the specified set the current set.
Displays version of networksetup tool.
Displays a list of all the commands available in the Network Setup Tool, with explanatory information.
Displays a list of commands with no detail.

/usr/sbin/networksetup
 

networksetup -listallnetworkservices

networksetup -setmanual "Built-in Ethernet" 192.168.100.100 255.255.255.0 192.168.100.1

networksetup -setdnsservers "Built-in Ethernet" 192.168.100.100 192.168.100.12

networksetup -setsearchdomains "Built-in Ethernet" company.com corp.com

networksetup -setwebproxy "Built-in Ethernet" proxy.company.com 80

networksetup -setwebproxy "Built-In Ethernet" proxy.company.com 80 On authusername authpassword

networksetup -duplicatenetworkservice "Built-In Ethernet" "Local LAN"

networksetup -getdnsservers "Built-In Ethernet"

networksetup -setMTU en0 1500

networksetup -setMedia en0 autoselect

networksetup -setMedia en0 100baseTX half-duplex

networksetup -createBond MyBond en0 en1

networksetup -addDeviceToBond en0 bond0

networksetup -setpppoepassword MyPPPoE - < ~/Desktop/MyPasswordFile.txt

networksetup -createlocation Home populate

systemsetup(8)

July 29, 2020 macOS