I'm currently working on a Raspberry Pi 3, trying to do some IoT stuff. I want it to be able to sniff on a usb wireless adapter, and send its data either via default wireless adapter or ethernet. I thought I could use udev, modifying /etc/udev/rules.d/70-persistent-net.rules. It seemed to me that I need to get the MAC address of the default wireless adapter. I got the MAC address using lshw:
root@raspberrypi:/etc/udev# lshw -class network *-usb:1 description: Wireless interface product: 802.11 n WLAN vendor: Ralink physical id: 4 bus info: usb@1:1.4 logical name: wlan1 version: 1.01 serial: 1.0 capabilities: usb-2.00 ethernet physical wireless configuration: broadcast=yes driver=rt2800 usbdriverversion=4.4.13-v7+ firmware=0.29 link=no maxpower=450mA multicast=yes speed=480Mbit/s wireless=IEEE 802.11bgn *-network:0 description: Wireless interface physical id: 2 logical name: wlan0 serial: b8:27:eb:e9:67:22 capabilities: ethernet physical wireless configuration: broadcast=yes driver=brcmfmac driverversion=188.8.131.52 firmware=01-df77e4a7 ip=192.168.0.102 multicast=yes wireless=IEEE 802.11bgn *-network:1 description: Ethernet interface physical id: 3 logical name: eth0 serial: b8:27:eb:bc:32:77 size: 100Mbit/s capacity: 100Mbit/s capabilities: ethernet physical tp mii 10bt 10bt-fd 100bt 100bt-fd autonegotiation configuration: autonegotiation=on broadcast=yes driver=smsc95xx driverversion=22-Aug-2005 duplex=full firmware=smsc95xx USB 2.0 Ethernet ip=10.42.0.11 link=yes multicast=yes port=MII speed=100Mbit/s
From this command, I can see the MAC address of my default wireless interface. Simply I'd put it in the rules and I'd be able to set the interface directly to wlan0. What I want is something more general: I don't want to do these setup in every device I set. I'll write a script and it'll get the wireless adapter's address for me.
root@raspberrypi:/etc/udev# sudo lshw -class network | grep b8:27:eb | sed 's/^.*serial: //' b8:27:eb:e9:67:22 b8:27:eb:bc:32:77
I used lshw, grep'd the MAC address that belonged to Raspberry Pi Foundation (b8:27:eb:xx:xx:xx), then get something like "serial: , and used sed to simply leave the MAC.
Then I figured that the ethernet adapter had also MAC address with same header.
My question is, how can I get only the RPi wireless adapter's MAC address as an output of a command?