How do I find the network interface that's connected to the Internet?
This machine could typically be connected via {eth0,eth1,usb0,wlan0}
. The best I could think of is:
sudo route | grep default | awk '{print $NF}'
Update: My favoured solution is:
$(for i in `ip r`; do echo $i; done | grep -A 1 dev | tail -n1)