Skip to content

Instantly share code, notes, and snippets.

@henri
Created February 6, 2020 20:11
Show Gist options
  • Save henri/e007b44a964989025bd81c2bb722d0cd to your computer and use it in GitHub Desktop.
Save henri/e007b44a964989025bd81c2bb722d0cd to your computer and use it in GitHub Desktop.
# This lines below are able to be placed into a script and then used to allow switching a system to a specific network interface at a specific time
# If you are looking to have this as an alias then visit this page : http://henri.shustak.org/github/handy-alias/
#
priority_interface_name="name_of_interface_to_prioritize"
echo sudo /usr/sbin/networksetup -ordernetworkservices \\\"${priority_interface_name}\\\" `/usr/sbin/networksetup -listallnetworkservices | grep -v 'An asterisk ' | sed s/\^'*'// | grep -xv "${priority_interface_name}" | sed 's/.*/\"&\"/' | tr '\n' ' ' | sed 's/.$//' | sed 's/\"/\\\\\"/g'` | tr -d "\\" | bash
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment