Fast Switch between LAN and Wifi on a MAC

Every Mac user would be familiar with the priority settings between USB/LAN and Wifi in the System Preferences > Network. I usually connect to Home broadband via Ethernet and to my Phone’s tethered connection via Wifi , especially when I am on some important meetings or any time network disruption is absolutely unacceptable. However when home broadband is gone, even though connectivity is there via Wifi Mac does not automatically switch to the healthy connection. So starts the invariable process to change the Network preferences manually. A few minutes later when broadband is back and I am lusting to use the 100 Mbps sweet speed of the connection again I have to re-do the process of manually switching.

This led me to think about how to script this out and thus I have set up two scripts,

To make LAN Primary and Wifi Secondary

#!/bin/bash

networksetup -ordernetworkservices "USB 10/100/1000 LAN" Wi-Fi "Bluetooth PAN" "Thunderbolt Bridge"
exit

To make Wifi Primary and LAN Secondary

#!/bin/bash

networksetup -ordernetworkservices Wi-Fi "USB 10/100/1000 LAN" "Bluetooth PAN" "Thunderbolt Bridge"
exit

By adding these bash files to the Dock ( next to Bin) I am now able to have instantaneous switch between LAN and Wifi at a single click.

Just dont forget to make the .command files executable by using the chmod a+x

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.