How do you programmatically determine under Linux if your current active ethernet interface is a wireless device?
For example, my machine has a wired and wireless interface, and the output of my ifconfig is:
eth0 Link encap:Ethernet HWaddr 64:b9:e9:cd:4f:b3
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:7700676 errors:0 dropped:0 overruns:0 frame:0
TX packets:3412854 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:3131639132 (3.1 GB) TX bytes:16826666276 (16.8 GB)
Interrupt:27 Base address:0x4000
eth2 Link encap:Ethernet HWaddr 01:16:4b:1b:90:c9
inet addr:192.168.1.152 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fa81::216:baff:de1b:91cc/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2307478 errors:15 dropped:0 overruns:0 frame:18469924
TX packets:1924909 errors:527 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2475924284 (2.4 GB) TX bytes:996430577 (996.4 MB)
Interrupt:23
Is there anything there that identifies one as wireless?
While it may be common for all network traffic to go over a single interface—especially in a single adapter system—it is not true in the general case. For example, my laptop commonly alternates routing over wi-fi and its 100baseT cable.
Inspect the output of
ip routefor a wlan entry. That, at least, indicates whether there could be wireless traffic. The default route is probably the best indication.Hardwired system:
Wi-fi system: