This will let you know which network interface you are actively using should you have Wi-Fi and Ethernet connected.
route get default | grep interface | awk '{print $2}'
Get name of network interface
ActiveNetwork=$(route get default | grep interface | awk '{print $2}') ActiveNetworkName=$(networksetup -listallhardwareports | grep -B 1 "$ActiveNetwork" | awk '/Hardware Port/{ print }'|cut -d " " -f3-) echo $ActiveNetwork echo $ActiveNetworkName
Last Updated on March 6, 2017