networksetup

Configuration tool for network settings in System Preferences.

Syntax
     networksetup [-listnetworkserviceorder] [-listallnetworkservices] [-listallhardwareports]
        [-detectnewhardware] [-getmacaddress hardwareport] [-getcomputername] [-setcomputername computername]
           [-getinfo netwksvc] [-setmanual netwksvc ip subnet router] [-setdhcp netwksvc [clientid]]
              [-setbootp netwksvc] [-setmanualwithdhcprouter netwksvc ip] [-getadditionalroutes netwksvc]
                 [-setadditionalroutes netwksvc [dest1 mask1 gate1] [dest2 mask2 gate2] ... [destN maskN gateN]]
                    [-setv4off netwksvc] [-setv6off netwksvc] [-setv6automatic netwksvc]
                       [-setv6linklocal netwksvc] [-setv6manual netwksvc address prefixLength router]
         [-getv6additionalroutes netwksvc]
            [-setv6additionalroutes netwksvc [dest1 prefixlength1 gate1] [dest2 prefixlength2 gate2] ... [destN prefixlengthN gateN]]
               [-getdnsservers netwksvc] [-setdnsservers netwksvc dns1 [dns2] [...]] [-getsearchdomains netwksvc]
                  [-setsearchdomains netwksvc domain1 [domain2] [...]] [-create6to4service networkservicename]
                     [-set6to4automatic netwksvc] [-set6to4manual netwksvc relayAddress] [-getftpproxy netwksvc]
                        [-setftpproxy netwksvc domain portnumber authenticated username password]
                           [-setftpproxystate netwksvc on | off] [-getwebproxy netwksvc]
                              [-setwebproxy netwksvc domain portnumber authenticated username password]
                                 [-setwebproxystate netwksvc on | off] [-getsecurewebproxy netwksvc]
                                    [-setsecurewebproxy netwksvc domain portnumber authenticated username password]
         [-setsecurewebproxystate netwksvc on | off]
            [-getstreamingproxy netwksvc] [-setstreamingproxy netwksvc domain portnumber authenticated username password]
               [-setstreamingproxystate netwksvc on | off] [-getgopherproxy netwksvc]
                  [-setgopherproxy netwksvc domain portnumber authenticated username password] [-setgopherproxystate netwksvc on | off]
                     [-getsocksfirewallproxy netwksvc] [-setsocksfirewallproxy netwksvc domain portnumber authenticated username password]
                        [-setsocksfirewallproxystate netwksvc on | off] [-getproxybypassdomains netwksvc]
                           [-setproxybypassdomains netwksvc domain1 [domain2] [...]] [-getproxyautodiscovery netwksvc]
                              [-setproxyautodiscovery netwksvc on | off] [-getpassiveftp netwksvc] [-setpassiveftp netwksvc 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]
                     [-getnetwksvcenabled netwksvc] [-setnetwksvcenabled netwksvc on | off]
                        [-createnetwksvc networkservicename hardwareport] [-renamenetwksvc netwksvc newnetworkservicename]
                           [-duplicatenetworkservice netwksvc newnetworkservicename] [-removenetworkservice netwksvc]
         [-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]

Options
     -listnetworkserviceorder
             Display 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.

     -listallnetworkservices
             Display a list of all the network services on the server’s hardware ports.  An asterisk (*) denotes that a
             network service is disabled.

     -listallhardwareports
             Display a list of hardware ports with corresponding device name and ethernet address.

     -detectnewhardware
             Detect new network hardware and create a default network service on the hardware.

     -getmacaddress hardwareport
             Display ethernet (or Wi-Fi) address for hardwareport or device specified.

     -getcomputername
             Display the computer name.

     -setcomputername computername
             Set the computer name to <computername>.  This name is used by AFP.

     -getinfo networkservice
             Display the IP address, subnet mask, router, and hardware address for the <networkservice> that you specify.

     -setmanual 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>.

     -setdhcp networkservice [clientid]
             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.

     -setbootp networkservice
             Set the TCP/IP configuration for the specified <networkservice> to use BOOTP.

     -setmanualwithdhcprouter networkservice ip
             Specify a manual IP address to use for DHCP for the specified <networkservice>.

     -getadditionalroutes networkservice
             Display the list of additional IPv4 routes configured for the service.

     -setadditionalroutes networkservice [dest1 mask1 gate1] [dest2 mask2 gate2] ... [destN maskN gateN]
             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.

     -setv4off networkservice
             Turn IPv4 off on the specified <networkservice>.

     -setv6off networkservice
             Turn IPv6 off on the specified <networkservice>.

     -setv6automatic networkservice
             Set IPv6 to get its addresses automatically for <networkservice>.

     -setv6linklocal networkservice
             Set IPv6 to only use link local for <networkservice>.

     -setv6manual ip prefixlength router
             Set IPv6 to get its addresses manually for <networkservice>.
             Specify the ip address, the prefix length and the router.

     -getv6additionalroutes networkservice
             Display the list of additional IPv6 routes configured for the service.
             
    -setv6additionalroutes networkservice [dest1 prefixlength1 gate1] [dest2 prefixlength2 gate2] ... [destN prefixlengthN gateN]
             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.

     -getdnsservers networkservice
             Display DNS info for <networkservice>.

     -setdnsservers networkservice dns1 [dns2] [...]
             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.

     -getsearchdomains networkservice
             Display Domain Name info for <networkservice>.

     -setsearchdomains networkservice domain1 [domain2] [...]
             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.

     -create6to4service -<newnetworkservicename>
             Create a new 6 to 4 service with name <newnetworkservicename>.

     -set6to4automatic -<newnetworkservicename>
             Set the 6 to 4 service such that it will get the relay address automatically.

     -set6to4manual -<newnetworkservicename> -<relayaddress>
             Set the 6 to 4 service such that it will get the relay address manually.
             Specify the <relayaddress> that you would like to set.

     -getftpproxy networkservice
             Display FTP proxy (server, port, enabled value) info for <networkservice>.

     -setftpproxy networkservice domain portnumber authenticated username password
             Set FTP 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.

     -setftpproxystate networkservice on | off
             Set FTP proxy on <networkservice> to either <on> or <off>.

     -getwebproxy networkservice
             Display the Web proxy (server, port, enabled value) info for <networkservice>.

     -setwebproxy 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.

     -setwebproxystate networkservice on | off
             Set Web proxy on <etworkservice> to either <on> or <off>.

     -getsecurewebproxy networkservice
             Display the Secure Web proxy (server, port, enabled value) info for <networkservice>.

     -setsecurewebproxy 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.

     -setsecurewebproxystate networkservice on | off
             Set SecureWeb proxy on <networkservice> to either <on> or <off>.

     -getstreamingproxy networkservice
             Display the Streaming proxy (server, port, enabled value) info for <networkservice>.

     -setstreamingproxy networkservice domain portnumber authenticated username password
             Set Streaming proxy for <networkservice> with <networkservice>.
             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.

     -setstreamingproxystate networkservice on | off
             Set Streamingproxy on <networkservice> to either <on> or <off>.

     -getgopherproxy networkservice
             Display the Gopher proxy (server, port, enabled value) info for <networkservice>.

     -setgopherproxy networkservice domain portnumber authenticated username password
             Set Gopher 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.

     -setgopherproxystate networkservice on | off
             Set Gopher proxy on <networkservice> to either <on> or <off>.

     -getsocksfirewallproxy networkservice
             Display the SOCKS Firewall proxy (server, port, enabled value) info for <networkservice>.

     -setsocksfirewallproxy 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.

     -setsocksfirewallproxystate networkservice on | off
             Set SOCKS Firewall proxy to  either <on> or <off>.

     -getproxybypassdomains networkservice
             Display the Bypass Domain Names for <networkservice>.

     -setproxybypassdomains 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.

     -getproxyautodiscovery networkservice
             Display the Proxy Auto Discover for <networkservice>.

     -setproxyautodiscovery networkservice on | off
             Set Proxy Auto Discover for <networkservice> to either <on> or <off>.

     -getpassiveftp networkservice
             Displays whether Passive FTP is on or off for <networkservice>.

     -setpassiveftp networkservice on | off
             Set Passive FTP to either <on> or <off>.

     -setautoproxyurl networkservice url
             Set proxy auto-config to url for <networkservice> and enable it.

     -getautoproxyurl networkservice
             Display the proxy auto-config (url, enabled) info for <networkservice>.

     -setsocksfirewallproxystate networkservice on | off
             Set SOCKS Firewall proxy to  either <on> or <off>.

     -getairportnetwork hardwarePort
             Display the current Wi-Fi Network.

     -setairportnetwork hardwarePort network [password]
             Set Wi-Fi Network to <network> using optional [password] if specified.

     -getairportpower hardwarePort
             Display whether Wi-Fi power is on or off.

     -setairportpower hardwarePort on | off
             Set Wi-Fi power to either <on> or <off>.

     -listpreferredwirelessnetworks hardwareport
             List the preferred wireless networks for <hardwareport>

     -addpreferredwirelessnetworkatindex 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.

     -removepreferredwirelessnetwork hardwareport network
             Remove <network> from the preferred wireless network list for <hardwareport>

     -removeallpreferredwirelessnetworks hardwareport
             Remove all networks from the preferred wireless network list for <hardwareport>

     -getnetworkserviceenabled networkservice
             Show whether a service is on or off (enabled or disabled).

     -setnetworkserviceenabled networkservice on | off
             Turn the specified network service on or off (enable or disable).
             
     -createnetworkservice networkservicename hardwareport
             Create a service named <networkservice> on port <hardwareport>. The new service will be enabled by default.

     -renamenetworkservice networkservice newnetworkservicename
             Rename the specified network service <networkservice> to <newnetworkservicename>.

     -duplicatenetworkservice networkservice newnetworkservicename
             Duplicate an existing network service <networkservice> and rename it to the specified name <newnetworkservicename>.

     -removenetworkservice networkservice
             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.

     -ordernetworkservices service1 [service2] [service3] [...]
             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").

     -setMTUAndMediaAutomatically hardwarePort
             Set hardwareport or device specified back to automatically setting the MTU and Media.

     -getMTU hardwareport
             Get the MTU value for hardwareport or device specified.

     -setMTU hardwarePort value
             Set MTU for hardwareport or device specified.

     -listValidMTURange hardwareport
             List the valid MTU range for hardwareport or device specified.

     -getMedia hardwareport
             Show both the current setting for media and the active media on hardwareport or device specified.

     -setMedia 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.

     -listValidMedia hardwareport
             List valid media options for hardwareport or device name.
             Enumerates available subtypes and options per subtype.

     -createVLAN name parentdevice tag
             Create a VLAN with the name <name> over the parent device <parentdevice> and with the tag <tag>.

     -deleteVLAN name parentdevice tag
             Delete the VLAN with the name <name> over the parent device <parentdevice> and with the tag <tag>.

     -listVLANs
             List the VLANs that have been created.

     -listdevicesthatsupportVLAN
             List the devices that support VLANs.

     -isBondSupported device
             Display YES if the device can be added to a bond.  NO if it cannot.

     -createBond name [device1] [device2] [...]
             Create a bond with the user-defined-name name and optionally add any listed devices if they support bonding.

     -deleteBond bond
             Delete the bond with the specified device-name.

     -addDeviceToBond device bond
             Add device to bond.

     -removeDeviceFromBond device bond
             Remove device from bond.

     -listBonds
             List of all bonds.

     -showBondStatus bond
             Display the status of the specified bond.

     -listpppoeservices
             List all PPPoE services in the current set.

     -showpppoestatus name
             Display the status of the PPPoE service with the specified name.

     -createpppoeservice device name account password [pppoeName]
             Create a PPPoE service on the specified device with the service name specified.

     -deletepppoeservice service
             Delete the service.

     -setpppoeaccountname service account
             Set the account name for the service.

     -setpppoepassword service password
             Set the password for the service.

     -connectpppoeservice service
             Connect the service.

     -disconnectpppoeservice service
             Disconnect the service.

     -listlocations
             List all network locations.

     -getcurrentlocation
             Display the name of the current set.

     -createlocation location [populate]
             Create a set with the user-defined-name name and optionally populate it with the default services.

     -deletelocation location
             Delete the set.

     -switchtolocation location
             Make the specified set the current set.

     -version
             Display the version of networksetup tool.

     -help   Display a list of all the commands available in the Network Setup Tool, with explanatory information.

     -printcommands
             Display a list of commands with no detail.

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

netwksvc = NetworkService.

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.

“In all things — except love — start with the exit strategy. Prepare for the ending. Almost anything is easier to get into than out of” ~ Kevin Kelly

Related macOS commands

hostname - Print or set system name.
net - Manage network resources.


 
Copyright © 1999-2024 SS64.com
Some rights reserved