NAME
networksetup —
configuration tool for network settings
in System Preferences.
SYNOPSIS
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] |
DESCRIPTION
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:
-listnetworkserviceorder- 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.
-listallnetworkservices- Displays a list of all the network services on the server's hardware ports. An asterisk (*) denotes that a network service is disabled.
-listallhardwareports- Displays list of hardware ports with corresponding device name and ethernet address.
-detectnewhardware- Detects new network hardware and creates a default network service on the hardware.
-getmacaddresshardwareport- Displays ethernet (or Wi-Fi) address for hardwareport or device specified.
-getcomputername- Displays the computer name.
-setcomputernamecomputername- Sets computer name to <computername>. This name is used by AFP.
-getinfonetworkservice- Displays the IP address, subnet mask, router, and hardware address for the <networkservice> that you specify.
-setmanualnetworkservice 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>.
-setdhcpnetworkservice [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.
-setbootpnetworkservice- Use this command to set the TCP/IP configuration for the specified <networkservice> to use BOOTP.
-setmanualwithdhcprouternetworkservice ip- Use this command to specify a manual IP address to use for DHCP for the specified <networkservice>.
-getadditionalroutesnetworkservice- Use this command to display the list of additional IPv4 routes configured for the service.
-setadditionalroutesnetworkservice [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.
-setv4offnetworkservice- Use this command to turn IPv4 off on the specified <networkservice>.
-setv6offnetworkservice- Use this command to turn IPv6 off on the specified <networkservice>.
-setv6automaticnetworkservice- Use this command to set IPv6 to get its addresses automatically for <networkservice>.
-setv6linklocalnetworkservice- Use this command to set IPv6 to only use link local for <networkservice>.
-setv6manualip 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.
-getv6additionalroutesnetworkservice- Use this command to display the list of additional IPv6 routes configured for the service.
-setv6additionalroutesnetworkservice [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. -getdnsserversnetworkservice- Displays DNS info for <networkservice>.
-setdnsserversnetworkservice 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.
-getsearchdomainsnetworkservice- Displays Domain Name info for <networkservice>.
-setsearchdomainsnetworkservice 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.
-create6to4service-<newnetworkservicename>- Use this command to create a new 6 to 4 service with name <newnetworkservicename>.
-set6to4automatic-<newnetworkservicename>- Use this command to set the 6 to 4 service such that it will get the relay address automatically.
-set6to4manual-<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.
-getwebproxynetworkservice- Displays Web proxy (server, port, enabled value) info for <networkservice>.
-setwebproxynetworkservice 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.
-setwebproxystatenetworkservice on | off- Set Web proxy on <networkservice> to either <on> or <off>.
-getsecurewebproxynetworkservice- Displays Secure Web proxy (server, port, enabled value) info for <networkservice>.
-setsecurewebproxynetworkservice 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.
-setsecurewebproxystatenetworkservice on | off- Set SecureWeb proxy on <networkservice> to either <on> or <off>.
-getsocksfirewallproxynetworkservice- Displays SOCKS Firewall proxy (server, port, enabled value) info for <networkservice>.
-setsocksfirewallproxynetworkservice 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.
-setsocksfirewallproxystatenetworkservice on | off- Set SOCKS Firewall proxy to either <on> or <off>.
-getproxybypassdomainsnetworkservice- Displays Bypass Domain Names for <networkservice>.
-setproxybypassdomainsnetworkservice 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.
-getproxyautodiscoverynetworkservice- Displays Proxy Auto Discover for <networkservice>.
-setproxyautodiscoverynetworkservice on | off- Set Proxy Auto Discover for <networkservice> to either <on> or <off>.
-setautoproxyurlnetworkservice url- Set proxy auto-config to url for <networkservice> and enable it.
-getautoproxyurlnetworkservice- Displays proxy auto-config (url, enabled) info for <networkservice>.
-setsocksfirewallproxystatenetworkservice on | off- Set SOCKS Firewall proxy to either <on> or <off>.
-getairportnetworkhardwareport- Displays current Wi-Fi Network.
-setairportnetworkhardwareport network [password]- Set Wi-Fi Network to <network> using optional [password] if specified.
-getairportpowerhardwareport- Displays whether Wi-Fi power is on or off.
-setairportpowerhardwareport on | off- Set Wi-Fi power to either <on> or <off>.
-listpreferredwirelessnetworkshardwareport- List the preferred wireless networks for <hardwareport>
-addpreferredwirelessnetworkatindexhardwareport 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.
-removepreferredwirelessnetworkhardwareport network- Remove <network> from the preferred wireless network list for <hardwareport>
-removeallpreferredwirelessnetworkshardwareport- Remove all networks from the preferred wireless network list for <hardwareport>
-getnetworkserviceenablednetworkservice- Displays whether a service is on or off (enabled or disabled).
-setnetworkserviceenablednetworkservice on | off- Use this command to turn the specified network service on or off (enable or disable).
-createnetworkservicenetworkservicename hardwareport- Create a service named <networkservice> on port <hardwareport>. The new service will be enabled by default.
-renamenetworkservicenetworkservice newnetworkservicename- Use this command to rename the specified network service <networkservice> to <newnetworkservicename>.
-duplicatenetworkservicenetworkservice newnetworkservicename- Use this command to duplicate an existing network service <networkservice> and rename it to the specified name <newnetworkservicename>.
-removenetworkservicenetworkservice- 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.
-ordernetworkservicesservice1 [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").
-setMTUAndMediaAutomaticallyhardwarePort- Set hardwareport or device specified back to automatically setting the MTU and Media.
-getMTUhardwareport- Get the MTU value for hardwareport or device specified.
-setMTUhardwarePort value- Set MTU for hardwareport or device specified.
-listValidMTURangehardwareport- List the valid MTU range for hardwareport or device specified.
-getMediahardwareport- Show both the current setting for media and the active media on hardwareport or device specified.
-setMediahardwareport 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.
-listValidMediahardwareport- List valid media options for hardwareport or device name. Enumerates available subtypes and options per subtype.
-createVLANname parentdevice tag- Create a VLAN with the name <name> over the parent device <parentdevice> and with the tag <tag>.
-deleteVLANname 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.
-isBondSupporteddevice- Displays YES if the device can be added to a bond. NO if it cannot.
-createBondname [device1] [device2] [...]- Create a bond with the user-defined-name name and optionally add any listed devices if they support bonding.
-deleteBondbond- Delete the bond with the specified device-name.
-addDeviceToBonddevice bond- Add device to bond.
-removeDeviceFromBonddevice bond- Remove device from bond.
-listBonds- List of all bonds.
-showBondStatusbond- Display the status of the specified bond.
-listpppoeservices- List all PPPoE services in the current set.
-showpppoestatusname- Display the status of the PPPoE service with the specified name.
-createpppoeservicedevice name account password [pppoeName]- Create a PPPoE service on the specified device with the service name specified.
-deletepppoeserviceservice- Delete the service.
-setpppoeaccountnameservice account- Set the account name for the service.
-setpppoepasswordservice password- Set the password for the service.
-connectpppoeserviceservice- Connect the service.
-disconnectpppoeserviceservice- Disconnect the service.
-listlocations- List all network locations.
-getcurrentlocation- Display the name of the current set.
-createlocationlocation [populate]- Create a set with the user-defined-name name and optionally populate it with the default services.
-deletelocationlocation- Delete the set.
-switchtolocationlocation- Make the specified set the current set.
-version- Displays version of networksetup tool.
-help- Displays a list of all the commands available in the Network Setup Tool, with explanatory information.
-printcommands- Displays a list of commands with no detail.
FILES
- /usr/sbin/networksetup
EXAMPLES
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