macOs 10.15 Change network service order. networksetup -ordernetworkservices

Basically, I'm trying to create a script to change the network services order.

I've been checking macOS KB, and checking the man page of networksetup and apparently I'd should to be able to accomplish this task with below commands.

##First I list my existing services with this command.
networksetup -listnetworkserviceorder | cut -d')' -f2 | sed '/^$/d' | sed '1d'
##Then I try to order my network services with networksetup -ordernetworkservices <service1> <service2> <service3> <...>
networksetup -ordernetworkservices "VPN1" "LAN" "Wi-Fi" "Bluetooth PAN" "Thunderbolt Bridge" "LWS-VPN-PAR"
A wrong number of network services... No changes have been made.
Note: Quotes must be used around service names which contain spaces (ie. "Built-in Ethernet").
** Error: The parameters were not valid.

However doesn't matter how I'm parsing the different services, I'm getting over and over again the same error.

A wrong number of network services... No changes have been made. Note: Quotes must be used around service names which contain spaces (ie. "Built-in Ethernet"). ** Error: The parameters were not valid.

This is driving mad, so any guidance or help would be really appreciated.

Thanks in advance.

Cheers Iñaky

1

1 Answer

You need to put the name of all network devices even if they are disabled.

Run networksetup -listnetworkserviceorder to get the list of all Interfaces like this.

An asterisk (*) denotes that a network service is disabled.

(1) Ethernet (Hardware Port: Ethernet, Device: en0)

(2) Wi-Fi (Hardware Port: Wi-Fi, Device: en1)

(3) Bluetooth PAN (Hardware Port: Bluetooth PAN, Device: en2)

(4) PCI Serial Adapter (22) (Hardware Port: PCI Serial Adapter (22), Device: pci-serial22)

(*) VPN Unlimited (Hardware Port: com.simplexsolutionsinc.vpnguardMac, Device: )

For e.g. If I need to change my order with "Wi-Fi" as the first service then I need to run the following command with all the interfaces/devices.

networksetup -ordernetworkservices "Wi-Fi" "Ethernet" "Bluetooth PAN" "PCI Serial Adapter (22)" "VPN Unlimited"

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like