I need to get the name of the network interface (e.g. eth0, wlan0) that is the currently-active one, the one sending and receiving traffic at the moment. When it's connected to WiFi, it would be wlan0 but when it's connected directly it would be eth0. Or something else, depending on the network devices on the system and which one is active. How can I find this out?
Please open a terminal and run the command:
The active interface will have an IP address and transmitted and received bytes. Here is an example:
On the other hand:
So, obviously, internet traffic is currently routed through wlan0, my wireless interface.
It is possible to have both ethernet and wireless connected simultaneously. Normally, Network Manager will disallow it, preferring ethernet over wireless because it is generally faster and more secure. If one wanted to use, say ethernet for the LAN and wireless for the WAN (internet), one would typically remove NM and set all the details manually in /etc/network/interfaces and would therefor know which interface was set up to use the internet.
No need for
You can have two or more external interfaces with LOWER-UP but generally a bad idea. Here's my laptop with loopback (notice LOWER_UP), down ethernet, wlan0 up and generating a signal, wlan4 (USB wifi) UP but NOT generating a signal, wlan4.mon monitor mode sniffing all stations on BSS (notice LOWER-UP). wlan4.mon does not transmit.